Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -264,8 +264,12 @@ // Deal with operations which have composite or void types. if (BO->isCommaOp()) { - if (!discard(LHS)) + if (this->discard(LHS)) return false; + if (RHS->getType()->isVoidType()) + return this->discard(RHS); + + // Otherwise, visit RHS and optionally discard its value. return Discard(this->visit(RHS)); } @@ -1650,10 +1654,12 @@ if (!visit(Exp)) return false; + if (Exp->getType()->isVoidType()) + return this->emitRetVoid(Exp); + if (std::optional T = classify(Exp)) return this->emitRet(*T, Exp); - else - return this->emitRetValue(Exp); + return this->emitRetValue(Exp); } /// Toplevel visitDecl(). Index: clang/test/AST/Interp/literals.cpp =================================================================== --- clang/test/AST/Interp/literals.cpp +++ clang/test/AST/Interp/literals.cpp @@ -791,6 +791,8 @@ (a); // expected-warning {{unused}} \ // ref-warning {{unused}} + (void)5, (void)6; + return 0; }