diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 0af473f9bd0802..590087e04b7474 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -2325,6 +2325,9 @@ bool Compiler::VisitCXXBindTemporaryExpr( template bool Compiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) { const Expr *Init = E->getInitializer(); + if (DiscardResult) + return this->discard(Init); + if (Initializing) { // We already have a value, just initialize that. return this->visitInitializer(Init) && this->emitFinishInit(E); @@ -2378,9 +2381,6 @@ bool Compiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) { if (!this->visitInitializer(Init) || !this->emitFinishInit(E)) return false; } - - if (DiscardResult) - return this->emitPopPtr(E); return true; } diff --git a/clang/test/AST/ByteCode/c23.c b/clang/test/AST/ByteCode/c23.c index e839fc716f5b52..f9157e40610cc3 100644 --- a/clang/test/AST/ByteCode/c23.c +++ b/clang/test/AST/ByteCode/c23.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -std=c23 -fexperimental-new-constant-interpreter -verify=expected,both %s // RUN: %clang_cc1 -std=c23 -verify=ref,both %s - +typedef typeof(nullptr) nullptr_t; const _Bool inf1 = (1.0/0.0 == __builtin_inf()); constexpr _Bool inf2 = (1.0/0.0 == __builtin_inf()); // both-error {{must be initialized by a constant expression}} \ @@ -22,3 +22,6 @@ char bar() { ((struct S *)buffer)->c = 'a'; return ((struct S *)buffer)->c; } + + +static_assert((nullptr_t){} == 0);