mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-28 08:10:25 +08:00
Fix array pointer stringification.
`int (*)[4];` should not be stringified as `int *[4];` Add stringification tests.
This commit is contained in:
parent
93a4ddfa63
commit
73ca09ff32
5
tccgen.c
5
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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user