mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-25 06:00:11 +08:00
Handle corner case for abstract decls
sometimes abstract decls in parameter lists left the returned name uninitialized potentially leading to segfaults, like in int f(int ()) { return 0; } Deal with this.
This commit is contained in:
parent
ef0397cf3d
commit
4b46e0ec63
4
tccgen.c
4
tccgen.c
@ -4591,12 +4591,14 @@ static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td)
|
||||
parse_attribute(ad);
|
||||
post = type_decl(type, ad, v, td);
|
||||
skip(')');
|
||||
}
|
||||
} else
|
||||
goto abstract;
|
||||
} else if (tok >= TOK_IDENT && (td & TYPE_DIRECT)) {
|
||||
/* type identifier */
|
||||
*v = tok;
|
||||
next();
|
||||
} else {
|
||||
abstract:
|
||||
if (!(td & TYPE_ABSTRACT))
|
||||
expect("identifier");
|
||||
*v = 0;
|
||||
|
@ -130,4 +130,15 @@ static enum myenum { L = -1 } L;
|
||||
void foo(void) {
|
||||
static enum myenum { L = -1 } L;
|
||||
}
|
||||
#elif defined test_abstract_decls
|
||||
int bar(const char *()); // abstract declarator here is okay
|
||||
int bar (const char *(*g)()) // should match this 'g' argument
|
||||
{
|
||||
g();
|
||||
return 42;
|
||||
}
|
||||
int foo(int ()) // abstract decl is wrong in definitions
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -59,3 +59,6 @@
|
||||
|
||||
[test_duplicate_def_2]
|
||||
60_errors_and_warnings.c:131: error: redeclaration of 'L'
|
||||
|
||||
[test_abstract_decls]
|
||||
60_errors_and_warnings.c:141: error: identifier expected
|
||||
|
Loading…
Reference in New Issue
Block a user