aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorDmitry Polukhin <34227995+dmpolukhin@users.noreply.github.com>2025-06-11 10:35:06 +0100
committerGitHub <noreply@github.com>2025-06-11 10:35:06 +0100
commit9797b5fcfbb9b9c96a219985f3623849bbd3956e (patch)
tree19e66813fec336409b431e54d687834bd506bae7 /clang/lib/AST/ExprConstant.cpp
parent7ffdf4240d62724dca7f42b37bd8671fefe17e17 (diff)
downloadllvm-9797b5fcfbb9b9c96a219985f3623849bbd3956e.zip
llvm-9797b5fcfbb9b9c96a219985f3623849bbd3956e.tar.gz
llvm-9797b5fcfbb9b9c96a219985f3623849bbd3956e.tar.bz2
[C++20][Modules] Fix false compilation error with constexpr (#143168)
Use declaresSameEntity when evaluating constexpr to avoid resetting computed union value due to using different instances of the merged field decl.
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index fa4e10e..27ea55e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -6844,7 +6844,8 @@ static bool HandleConstructorCall(const Expr *E, const LValue &This,
// FIXME: In this case, the values of the other subobjects are
// specified, since zero-initialization sets all padding bits to zero.
if (!Value->hasValue() ||
- (Value->isUnion() && Value->getUnionField() != FD)) {
+ (Value->isUnion() &&
+ !declaresSameEntity(Value->getUnionField(), FD))) {
if (CD->isUnion())
*Value = APValue(FD);
else