Author: Timm Baeder Date: 2024-10-14T15:11:39+02:00 New Revision: 4c78c8cc2184125f86f9df194e1820b0da3158fa
URL: https://github.com/llvm/llvm-project/commit/4c78c8cc2184125f86f9df194e1820b0da3158fa DIFF: https://github.com/llvm/llvm-project/commit/4c78c8cc2184125f86f9df194e1820b0da3158fa.diff LOG: [clang][bytecode] Fix discarding block expressions (#112185) Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/test/SemaCXX/block-packs.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index b2663714340b93..51115907629d67 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3416,6 +3416,9 @@ bool Compiler<Emitter>::VisitCXXDeleteExpr(const CXXDeleteExpr *E) { template <class Emitter> bool Compiler<Emitter>::VisitBlockExpr(const BlockExpr *E) { + if (DiscardResult) + return true; + const Function *Func = nullptr; if (auto F = Compiler<ByteCodeEmitter>(Ctx, P).compileObjCBlock(E)) Func = F; diff --git a/clang/test/SemaCXX/block-packs.cpp b/clang/test/SemaCXX/block-packs.cpp index 4f3d68a727b7c9..8f63c98fa27451 100644 --- a/clang/test/SemaCXX/block-packs.cpp +++ b/clang/test/SemaCXX/block-packs.cpp @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fsyntax-only -verify -Wno-unused %s // RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fsyntax-only -verify -Wno-unused %s -frecovery-ast -frecovery-ast-type +// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fsyntax-only -verify -Wno-unused -fexperimental-new-constant-interpreter %s +// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fsyntax-only -verify -Wno-unused -frecovery-ast -frecovery-ast-type -fexperimental-new-constant-interpreter %s + template <typename ...Ts> void f() { ((^ { Ts t; }), ...); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits