Open ebdd6ebc-1612-4e9b-aee1-f7d2b6361d5f opened 5 years ago
The issue still reproduces as of Clang 16.0.0: https://gcc.godbolt.org/z/7zeKdEYPT
Interesting to note that removing the forward declaration on line 1 causes the diagnostic to go away, so I suspect the issue has to do with redeclaration merging.
@llvm/issue-subscribers-clang-frontend
@llvm/issue-subscribers-c
Extended Description
The following C11 program (prog.c) should compile without error:
struct T;
void f( struct S { struct T { int a; } *b; } );
struct T { int c; };
int main() { }
When I compile it with clang prog.c -std=c11 -pedantic-errors "-w" i get the following unexpected error:
error: redefinition of 'T'
This is wrong since the struct definition inside the function declaration has function prototype scope and therefore should be independent of the struct definition in the file scope.
Online compiler link:
https://wandbox.org/permlink/UpaD0znT5jkohSNP
Note that gcc does not give any errors.