Skip to content

Commit 3263ad7

Browse files
tbaederrtru
authored andcommitted
[clang] Remove hasValue() check in RecordExprEvaluator::VisitCXXConstructExpr() (llvm#154610)
When initializing an anonymous struct via an `IndirectFieldDecl`, we create an `APValue` for the struct, but we leave the fields uninitialized. This would later cause the `CXXConstructExpr` that initializes the anonymous struct member to not do anything since its `APValue` already had a value (but the member didn't). Just remove the check for an `APValue` that already has a value from `RecordExprEvaluator::VisitCXXConstructExpr()`. Fixes llvm#154567
1 parent a2f2f1a commit 3263ad7

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10932,10 +10932,6 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
1093210932

1093310933
bool ZeroInit = E->requiresZeroInitialization();
1093410934
if (CheckTrivialDefaultConstructor(Info, E->getExprLoc(), FD, ZeroInit)) {
10935-
// If we've already performed zero-initialization, we're already done.
10936-
if (Result.hasValue())
10937-
return true;
10938-
1093910935
if (ZeroInit)
1094010936
return ZeroInitialization(E, T);
1094110937

clang/test/SemaCXX/constant-expression-cxx11.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,3 +2615,19 @@ namespace DoubleCapture {
26152615
};
26162616
}
26172617
}
2618+
2619+
namespace GH154567 {
2620+
struct T {
2621+
int i;
2622+
};
2623+
2624+
struct S {
2625+
struct { // expected-warning {{GNU extension}}
2626+
T val;
2627+
};
2628+
constexpr S() : val() {}
2629+
};
2630+
2631+
constexpr S s{};
2632+
static_assert(s.val.i == 0, "");
2633+
}

0 commit comments

Comments
 (0)