summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2017-12-12 16:02:06 +0000
committerErich Keane <erich.keane@intel.com>2017-12-12 16:02:06 +0000
commitbd2197c0c1ad4e7ed648880a90a4ab16064942ae (patch)
tree59bad2bd44cd7a0cc7008930a3b7786391b36753 /clang
parentfb68c48a8201a5d6066994699e098b267d4e418c (diff)
downloadbcm5719-llvm-bd2197c0c1ad4e7ed648880a90a4ab16064942ae.tar.gz
bcm5719-llvm-bd2197c0c1ad4e7ed648880a90a4ab16064942ae.zip
Fix ICE when __has_unqiue_object_representations called with invalid decl
llvm-svn: 320489
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/ASTContext.cpp3
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp3
-rw-r--r--clang/test/SemaCXX/type-traits.cpp8
3 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index e6471be2041..34a925020e8 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2279,6 +2279,9 @@ bool ASTContext::hasUniqueObjectRepresentations(QualType Ty) const {
if (Ty->isRecordType()) {
const RecordDecl *Record = Ty->getAs<RecordType>()->getDecl();
+ if (Record->isInvalidDecl())
+ return false;
+
if (Record->isUnion())
return unionHasUniqueObjectRepresentations(*this, Record);
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 9c842ded1e1..641d583944f 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4958,7 +4958,7 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT,
EnterExpressionEvaluationContext Unevaluated(
Self, Sema::ExpressionEvaluationContext::Unevaluated);
Sema::SFINAETrap SFINAE(Self, /*AccessCheckingSFINAE=*/true);
- Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl());
+ Sema::ContextRAII TUContext(Self, Self.Context.getTranslationUnitDecl()); {
ExprResult Result = Self.BuildBinOp(/*S=*/nullptr, KeyLoc, BO_Assign, &Lhs,
&Rhs);
if (Result.isInvalid() || SFINAE.hasErrorOccurred())
@@ -4981,6 +4981,7 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT,
llvm_unreachable("unhandled type trait");
return false;
+ }
}
default: llvm_unreachable("not a BTT");
}
diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp
index d4d19682182..b334e507554 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -2661,3 +2661,11 @@ static_assert(sizeof(CanBeUniqueIfNoPadding) != 16 ||
has_unique_object_representations<CanBeUniqueIfNoPadding>::value,
"inherit from std layout");
+namespace ErrorType {
+ struct S; //expected-note{{forward declaration of 'ErrorType::S'}}
+
+ struct T {
+ S t; //expected-error{{field has incomplete type 'ErrorType::S'}}
+ };
+ bool b = __has_unique_object_representations(T);
+};
OpenPOWER on IntegriCloud