[clang] [clang][bytecode] Fix discarding block expressions (PR #112185)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 14 04:46:42 PDT 2024
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/112185
None
>From 8a1887cc301342f11a53aaed903e2f59577ac739 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 14 Oct 2024 13:44:54 +0200
Subject: [PATCH] [clang][bytecode] Fix discarding block expressions
---
clang/lib/AST/ByteCode/Compiler.cpp | 3 +++
clang/test/SemaCXX/block-packs.cpp | 3 +++
2 files changed, 6 insertions(+)
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; }), ...);
More information about the cfe-commits
mailing list