Don't crash while trying to diagnose a function declared at block scope with an
incomplete return type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148088 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 4dcf1db..20309ee 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -4945,7 +4945,8 @@
// 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 1f17a9e..0f7530b 100644
--- a/lib/Sema/SemaFixItUtils.cpp
+++ b/lib/Sema/SemaFixItUtils.cpp
@@ -180,9 +180,11 @@
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;
}