This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi, For test-case containing only the following declaration: static struct undefined_struct object; gcc rejects it at -O0 in assemble_variable() with error "storage size of <var> is unknown", however no error is reported when compiled with -O2. AFAIU that happens because at -O2, analyze_function() removes the symbol "object" from symbol table and assemble_variable() has no chance to process it. g++ rejects it during parsing. I tried similarly in C FE by adding a check for decl with incomplete struct/union type in finish_decl(), however that fails to compile the following case: typedef struct foo foo_t; foo_t x; struct foo { int i; }; g++ rejects the above case as well but gcc accepts it. Do C and C++ standards differ in this regard ? So instead of finish_decl(), I added check for incomplete struct/union in check_global_declaration(), which is called by analyze_function() before removing unused nodes. The patch regresses Wcxx-compat-8.c and declspecs-1.c because the error "storage size of <var> is unknown" shows up in these test-cases. I modified the test-cases to accept that error. Does the patch look OK ? Thank you, Prathamesh
Attachment:
patch.diff
Description: Text document
Attachment:
ChangeLog
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |