forked from OSchip/llvm-project
Suppress constant initializer checking when the declaration isn't valid.
This prevents emitting diagnostics which are almost certainly useless. (Note that the test is checking that we emit only one diagnostic.) llvm-svn: 65101
This commit is contained in:
parent
92cfae68e9
commit
ce98257691
|
@ -2457,7 +2457,8 @@ void Sema::AddInitializerToDecl(DeclTy *dcl, ExprArg init, bool DirectInit) {
|
|||
VDecl->setInvalidDecl();
|
||||
|
||||
// C++ 3.6.2p2, allow dynamic initialization of static initializers.
|
||||
if (!getLangOptions().CPlusPlus) {
|
||||
// Don't check invalid declarations to avoid emitting useless diagnostics.
|
||||
if (!getLangOptions().CPlusPlus && !VDecl->isInvalidDecl()) {
|
||||
if (SC == VarDecl::Static) // C99 6.7.8p4.
|
||||
CheckForConstantInitializer(Init, DclT);
|
||||
}
|
||||
|
@ -2471,7 +2472,8 @@ void Sema::AddInitializerToDecl(DeclTy *dcl, ExprArg init, bool DirectInit) {
|
|||
VDecl->setInvalidDecl();
|
||||
|
||||
// C++ 3.6.2p2, allow dynamic initialization of static initializers.
|
||||
if (!getLangOptions().CPlusPlus) {
|
||||
// Don't check invalid declarations to avoid emitting useless diagnostics.
|
||||
if (!getLangOptions().CPlusPlus && !VDecl->isInvalidDecl()) {
|
||||
// C99 6.7.8p4. All file scoped initializers need to be constant.
|
||||
CheckForConstantInitializer(Init, DclT);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
// RUN: clang %s -verify -fsyntax-only
|
||||
|
||||
int a;
|
||||
struct {int x;} x = a; // expected-error {{incompatible type initializing 'int', expected 'struct <anonymous>'}}
|
Loading…
Reference in New Issue