diff options
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaFixItUtils.cpp | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 4dcf1db2cf..20309ee51c 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4945,7 +4945,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // Empty parens mean value-initialization, and no parens mean default // initialization. These are equivalent if the default constructor is // user-provided, or if zero-initialization is a no-op. - if (RD && (RD->isEmpty() || RD->hasUserProvidedDefaultConstructor())) + if (RD && RD->hasDefinition() && + (RD->isEmpty() || RD->hasUserProvidedDefaultConstructor())) Diag(C.Loc, diag::note_empty_parens_default_ctor) << FixItHint::CreateRemoval(ParenRange); else if (const char *Init = getFixItZeroInitializerForType(T)) diff --git a/lib/Sema/SemaFixItUtils.cpp b/lib/Sema/SemaFixItUtils.cpp index 1f17a9e83e..0f7530b415 100644 --- a/lib/Sema/SemaFixItUtils.cpp +++ b/lib/Sema/SemaFixItUtils.cpp @@ -180,9 +180,11 @@ const char *Sema::getFixItZeroInitializerForType(QualType T) const { if (T->isScalarType()) return " = 0"; const CXXRecordDecl *RD = T->getAsCXXRecordDecl(); - if (LangOpts.CPlusPlus0x && RD && !RD->hasUserProvidedDefaultConstructor()) + if (!RD || !RD->hasDefinition()) + return 0; + if (LangOpts.CPlusPlus0x && !RD->hasUserProvidedDefaultConstructor()) return "{}"; - if (T->isAggregateType()) + if (RD->isAggregate()) return " = {}"; return 0; } |