diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Sema/SemaFixItUtils.cpp | 6 | ||||
-rw-r--r-- | clang/test/SemaCXX/decl-expr-ambiguity.cpp | 4 |
3 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 4dcf1db2cf8..20309ee51cc 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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/clang/lib/Sema/SemaFixItUtils.cpp b/clang/lib/Sema/SemaFixItUtils.cpp index 1f17a9e83e7..0f7530b415c 100644 --- a/clang/lib/Sema/SemaFixItUtils.cpp +++ b/clang/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; } diff --git a/clang/test/SemaCXX/decl-expr-ambiguity.cpp b/clang/test/SemaCXX/decl-expr-ambiguity.cpp index f6dbe2f3398..6f4d08cc686 100644 --- a/clang/test/SemaCXX/decl-expr-ambiguity.cpp +++ b/clang/test/SemaCXX/decl-expr-ambiguity.cpp @@ -50,10 +50,14 @@ struct RAII { void func(); namespace N { + struct S; + void emptyParens() { RAII raii(); // expected-warning {{function declaration}} expected-note {{remove parentheses to declare a variable}} int a, b, c, d, e, // expected-note {{change this ',' to a ';' to call 'func'}} func(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} + + S s(); // expected-warning {{function declaration}} } } |