diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-01 00:07:14 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-01 00:07:14 +0000 |
commit | 9a84dc0b360662e352428b2dba85c0351d3d1328 (patch) | |
tree | d6d6b32653a193fcb9f6594de5091a31d7fc2dbe /clang/lib/AST/ExprConstant.cpp | |
parent | f18d747107de3504ceac73abc1ec351fe8f58c95 (diff) | |
download | bcm5719-llvm-9a84dc0b360662e352428b2dba85c0351d3d1328.tar.gz bcm5719-llvm-9a84dc0b360662e352428b2dba85c0351d3d1328.zip |
[c++20] Fix crash when constant-evaluating an assignment with a
reference member access on its left-hand side.
llvm-svn: 373276
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index f91e0782b89..5659a0eced6 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -5258,7 +5258,9 @@ static bool HandleUnionActiveMemberChange(EvalInfo &Info, const Expr *LHSExpr, // -- If E is of the form A.B, S(E) contains the elements of S(A)... if (auto *ME = dyn_cast<MemberExpr>(E)) { auto *FD = dyn_cast<FieldDecl>(ME->getMemberDecl()); - if (!FD) + // Note that we can't implicitly start the lifetime of a reference, + // so we don't need to proceed any further if we reach one. + if (!FD || FD->getType()->isReferenceType()) break; // ... and also contains A.B if B names a union member |