Skip to content

array of function variable mishandled #1041

Closed

Description

@rhinoshorn

test.cfg:
sp_func_call_paren = remove

input:
void (*g_func_table[32])(void);

expected:
same as input

output:
void(*g_func_table[32])(void);
space between type and '(' removed.

Activity

  1. guy-maurel commented on Apr 8, 2017

    @guy-maurel
    Contributor

    clang says:

    VarDecl 0x25f47d8 <rhinoshorn.cpp:1:1, col:30> col:8 g_func_table 'void (*[32])(void)'
    

    is it what you expected to have?
    Could you push a complete example, with use of it?

  2. rhinoshorn commented on Apr 23, 2017

    @rhinoshorn
    Author

    @guy-maurel Yes, that's what I expected.

    I put example code blocks below due to company firewall policy.

    test.cfg:

    sp_func_call_paren = remove
    

    test.c:

    #include <stdio.h>
    
    void func_dummy() { printf("%s\n", __func__); }
    void func_0() { printf("%s\n", __func__); }
    void func_1() { printf("%s\n", __func__); }
    void func_2() { printf("%s\n", __func__); }
    
    void (*g_func_table[32])(void) = {
            [0 ... 31] = func_dummy,
            [0] = func_0,
            [1] = func_1,
            [2] = func_2,
    };
    
    int main(int argc, char **argv)
    {
        int i;
        for(i = 0; i < 32; i++) {
            g_func_table[i]();
        }
        return 0;
    }

    test.c.expected:

    #include <stdio.h>
    
    void func_dummy() {
    	printf("%s\n", __func__);
    }
    void func_0() {
    	printf("%s\n", __func__);
    }
    void func_1() {
    	printf("%s\n", __func__);
    }
    void func_2() {
    	printf("%s\n", __func__);
    }
    
    void (*g_func_table[32])(void) = {
    	[0 ... 31] = func_dummy,
    	[0] = func_0,
    	[1] = func_1,
    	[2] = func_2,
    };
    
    int main(int argc, char **argv)
    {
    	int i;
    	for(i = 0; i < 32; i++) {
    		g_func_table[i]();
    	}
    	return 0;
    }

    test.c.uncrustify:

    #include <stdio.h>
    
    void func_dummy() {
    	printf("%s\n", __func__);
    }
    void func_0() {
    	printf("%s\n", __func__);
    }
    void func_1() {
    	printf("%s\n", __func__);
    }
    void func_2() {
    	printf("%s\n", __func__);
    }
    
    void(*g_func_table[32])(void) = {
    	[0 ... 31] = func_dummy,
    	[0] = func_0,
    	[1] = func_1,
    	[2] = func_2,
    };
    
    int main(int argc, char **argv)
    {
    	int i;
    	for(i = 0; i < 32; i++) {
    		g_func_table[i]();
    	}
    	return 0;
    }
  3. added a commit that references this issue on May 9, 2017
  4. added a commit that references this issue on May 11, 2017
  5. gmaurel commented on May 11, 2017

    @gmaurel
    Collaborator

    is fixed

  6. rhinoshorn commented on May 14, 2017

    @rhinoshorn
    Author

    thank you~! :)

  7. gmaurel commented on Dec 18, 2017

    @gmaurel
    Collaborator

    The solution is not complicated enough to solve the problem if assignment is NOT in the same block.

  8. added a commit that references this issue on Dec 19, 2017
  9. guy-maurel commented on Dec 19, 2017

    @guy-maurel
    Contributor

    #1512 is a better bugfix.
    Thanks to @aneesh1127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions