Fix crash on invalid code

like on 'enum myenum { L = -1 } L;'.  It's a bit tedious as
there are two paths (for global vs local symbols), and because
the scope and enum_val share same storage.
This commit is contained in:
Michael Matz
2019-03-08 17:58:25 +01:00
parent b082659f19
commit ef0397cf3d
3 changed files with 22 additions and 2 deletions

View File

@@ -124,4 +124,10 @@ void f() { _Generic((int const *[]){0}, int:0); }
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); }
#elif defined test_duplicate_def_1
static enum myenum { L = -1 } L;
#elif defined test_duplicate_def_2
void foo(void) {
static enum myenum { L = -1 } L;
}
#endif

View File

@@ -53,3 +53,9 @@
[test_array_to_str]
60_errors_and_warnings.c:126: error: type 'int (*)[3]' does not match any association
[test_duplicate_def_1]
60_errors_and_warnings.c:128: error: redefinition of 'L'
[test_duplicate_def_2]
60_errors_and_warnings.c:131: error: redeclaration of 'L'