Skip to content

Commit b44763c

Browse files
authored
[clang][Interp] Fix scalar inits of void type (#69868)
1 parent 3fb5b18 commit b44763c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,8 +1597,12 @@ bool ByteCodeExprGen<Emitter>::VisitOffsetOfExpr(const OffsetOfExpr *E) {
15971597
template <class Emitter>
15981598
bool ByteCodeExprGen<Emitter>::VisitCXXScalarValueInitExpr(
15991599
const CXXScalarValueInitExpr *E) {
1600-
return this->visitZeroInitializer(classifyPrim(E->getType()), E->getType(),
1601-
E);
1600+
QualType Ty = E->getType();
1601+
1602+
if (Ty->isVoidType())
1603+
return true;
1604+
1605+
return this->visitZeroInitializer(classifyPrim(Ty), Ty, E);
16021606
}
16031607

16041608
template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {

clang/test/AST/Interp/literals.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ namespace ScalarTypes {
5656
};
5757
static_assert(getScalar<E>() == First, "");
5858
/// FIXME: Member pointers.
59+
60+
#if __cplusplus >= 201402L
61+
constexpr void Void(int n) {
62+
void(n + 1);
63+
void();
64+
}
65+
constexpr int void_test = (Void(0), 1);
66+
static_assert(void_test == 1, "");
67+
#endif
5968
}
6069

6170
namespace IntegralCasts {

0 commit comments

Comments
 (0)