diff --git a/tccgen.c b/tccgen.c index dece3745..cf16b4d0 100644 --- a/tccgen.c +++ b/tccgen.c @@ -2964,7 +2964,10 @@ static void type_to_str(char *buf, int buf_size, case VT_PTR: s = type->ref; if (t & VT_ARRAY) { - snprintf(buf1, sizeof(buf1), "%s[%d]", varstr ? varstr : "", s->c); + if (varstr && '*' == *varstr) + snprintf(buf1, sizeof(buf1), "(%s)[%d]", varstr, s->c); + else + snprintf(buf1, sizeof(buf1), "%s[%d]", varstr ? varstr : "", s->c); type_to_str(buf, buf_size, &s->type, buf1); goto no_var; } diff --git a/tests/tests2/60_errors_and_warnings.c b/tests/tests2/60_errors_and_warnings.c index b32a3db1..289c0304 100644 --- a/tests/tests2/60_errors_and_warnings.c +++ b/tests/tests2/60_errors_and_warnings.c @@ -118,4 +118,10 @@ enum e5; void f3(enum e4 e); void f3(enum e5 e); +#elif defined test_ptr_to_str +void f() { _Generic((int const *[]){0}, int:0); } +#elif defined test_fnptr_to_str +void f() { _Generic((int (*(*)(float,char))(double,int)){0}, int:0); } +#elif defined test_array_to_str +void f() { _Generic((int(*)[3]){0}, int:0); } #endif diff --git a/tests/tests2/60_errors_and_warnings.expect b/tests/tests2/60_errors_and_warnings.expect index 5f2fa1c2..aae5ce9e 100644 --- a/tests/tests2/60_errors_and_warnings.expect +++ b/tests/tests2/60_errors_and_warnings.expect @@ -44,3 +44,12 @@ [test_enum_compat] 60_errors_and_warnings.c:119: error: incompatible types for redefinition of 'f3' + +[test_ptr_to_str] +60_errors_and_warnings.c:122: error: type 'const int **' does not match any association + +[test_fnptr_to_str] +60_errors_and_warnings.c:124: error: type 'int (*(*)(float, char))(double, int)' does not match any association + +[test_array_to_str] +60_errors_and_warnings.c:126: error: type 'int (*)[3]' does not match any association