Skip to content

Commit

Permalink
[clang][Interp] Fix scalar inits of void type (#69868)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed Oct 24, 2023
1 parent 3fb5b18 commit b44763c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,8 +1597,12 @@ bool ByteCodeExprGen<Emitter>::VisitOffsetOfExpr(const OffsetOfExpr *E) {
template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitCXXScalarValueInitExpr(
const CXXScalarValueInitExpr *E) {
return this->visitZeroInitializer(classifyPrim(E->getType()), E->getType(),
E);
QualType Ty = E->getType();

if (Ty->isVoidType())
return true;

return this->visitZeroInitializer(classifyPrim(Ty), Ty, E);
}

template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
Expand Down
9 changes: 9 additions & 0 deletions clang/test/AST/Interp/literals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ namespace ScalarTypes {
};
static_assert(getScalar<E>() == First, "");
/// FIXME: Member pointers.

#if __cplusplus >= 201402L
constexpr void Void(int n) {
void(n + 1);
void();
}
constexpr int void_test = (Void(0), 1);
static_assert(void_test == 1, "");
#endif
}

namespace IntegralCasts {
Expand Down

0 comments on commit b44763c

Please sign in to comment.