`int (*)[4];` should not be stringified as `int *[4];` Add stringification tests.
Unified · Split
| @@ -2964,7 +2964,10 @@ static void type_to_str(char *buf, int buf_size, · 2963 unmodified lines | ||
| 2964 | 2964 | case VT_PTR: |
| 2965 | 2965 | s = type->ref; |
| 2966 | 2966 | if (t & VT_ARRAY) { |
| 2967 | − snprintf(buf1, sizeof(buf1), "%s[%d]", varstr ? varstr : "", s->c); | |
| 2967 | + if (varstr && '*' == *varstr) | |
| 2968 | + snprintf(buf1, sizeof(buf1), "(%s)[%d]", varstr, s->c); | |
| 2969 | + else | |
| 2970 | + snprintf(buf1, sizeof(buf1), "%s[%d]", varstr ? varstr : "", s->c); | |
| 2968 | 2971 | type_to_str(buf, buf_size, &s->type, buf1); |
| 2969 | 2972 | goto no_var; |
| 2970 | 2973 | } |
| @@ -118,4 +118,10 @@ enum e5; · 117 unmodified lines | ||
| 118 | 118 | void f3(enum e4 e); |
| 119 | 119 | void f3(enum e5 e); |
| 120 | 120 | |
| 121 | +#elif defined test_ptr_to_str | |
| 122 | +void f() { _Generic((int const *[]){0}, int:0); } | |
| 123 | +#elif defined test_fnptr_to_str | |
| 124 | +void f() { _Generic((int (*(*)(float,char))(double,int)){0}, int:0); } | |
| 125 | +#elif defined test_array_to_str | |
| 126 | +void f() { _Generic((int(*)[3]){0}, int:0); } | |
| 121 | 127 | #endif |
| @@ -44,3 +44,12 @@ · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | [test_enum_compat] |
| 46 | 46 | 60_errors_and_warnings.c:119: error: incompatible types for redefinition of 'f3' |
| 47 | + | |
| 48 | +[test_ptr_to_str] | |
| 49 | +60_errors_and_warnings.c:122: error: type 'const int **' does not match any association | |
| 50 | + | |
| 51 | +[test_fnptr_to_str] | |
| 52 | +60_errors_and_warnings.c:124: error: type 'int (*(*)(float, char))(double, int)' does not match any association | |
| 53 | + | |
| 54 | +[test_array_to_str] | |
| 55 | +60_errors_and_warnings.c:126: error: type 'int (*)[3]' does not match any association | |