summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2019-05-13 19:29:23 +0000
committerMarshall Clow <mclow.lists@gmail.com>2019-05-13 19:29:23 +0000
commitce78105558d56b78d80f6c598623d3fcb7496402 (patch)
treec7eeaab8c8e0241fd5cbb39540cab698f1c09fe8 /clang/lib/Sema/SemaExprCXX.cpp
parent5f9afe953deabd919da9d6aff88d9e3480d8d1f2 (diff)
downloadbcm5719-llvm-ce78105558d56b78d80f6c598623d3fcb7496402.tar.gz
bcm5719-llvm-ce78105558d56b78d80f6c598623d3fcb7496402.zip
Make more friendly with unions. Reviewed as https://reviews.llvm.org/D61858
llvm-svn: 360614
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 8f00887ebc4..87dc3a9a54a 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5118,8 +5118,15 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT,
assert(Self.Context.hasSameUnqualifiedType(LhsT, RhsT)
== (lhsRecord == rhsRecord));
+ // Unions are never base classes, and never have base classes.
+ // It doesn't matter if they are complete or not. See PR#41843
+ if (lhsRecord && lhsRecord->getDecl()->isUnion())
+ return false;
+ if (rhsRecord && rhsRecord->getDecl()->isUnion())
+ return false;
+
if (lhsRecord == rhsRecord)
- return !lhsRecord->getDecl()->isUnion();
+ return true;
// C++0x [meta.rel]p2:
// If Base and Derived are class types and are different types
OpenPOWER on IntegriCloud