[clang] [clang][bytecode] Don't use throw as invalid in c++26 (PR #181150)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 12 06:21:45 PST 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/181150
Don't pass a combination of `-std=c++26` and `-fcxx-exceptions` to tests and then try to use `throw` as an invalid statement. C++26 actually has working exceptions at compile time, even if that is currently not implemented.
>From 2bb7506f04ffbcea4ec3df693a6e44856bfa45e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 12 Feb 2026 15:18:17 +0100
Subject: [PATCH] [clang][bytecode] Don't use throw as invalid in c++26
---
clang/test/AST/ByteCode/cxx26.cpp | 6 +++---
clang/test/AST/ByteCode/placement-new.cpp | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/clang/test/AST/ByteCode/cxx26.cpp b/clang/test/AST/ByteCode/cxx26.cpp
index acab347963923..8035a2640ff5f 100644
--- a/clang/test/AST/ByteCode/cxx26.cpp
+++ b/clang/test/AST/ByteCode/cxx26.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++26 -fsyntax-only -fcxx-exceptions -verify=ref,both %s
-// RUN: %clang_cc1 -std=c++26 -fsyntax-only -fcxx-exceptions -verify=expected,both %s -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify=ref,both %s
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify=expected,both %s -fexperimental-new-constant-interpreter
namespace std {
using size_t = decltype(sizeof(0));
@@ -49,7 +49,7 @@ static_assert(*f == 12);
namespace ExplicitThisInBacktrace {
struct S {
constexpr void foo(this const S& self) {
- throw; // both-note {{not valid in a constant expression}}
+ __builtin_abort(); // both-note {{not valid in a constant expression}}
}
};
diff --git a/clang/test/AST/ByteCode/placement-new.cpp b/clang/test/AST/ByteCode/placement-new.cpp
index 503e456565f5d..2c302ef7a8e7b 100644
--- a/clang/test/AST/ByteCode/placement-new.cpp
+++ b/clang/test/AST/ByteCode/placement-new.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++2c -fcxx-exceptions -fexperimental-new-constant-interpreter -verify=expected,both %s -DBYTECODE
-// RUN: %clang_cc1 -std=c++2c -fcxx-exceptions -verify=ref,both %s
+// RUN: %clang_cc1 -std=c++2c -fexperimental-new-constant-interpreter -verify=expected,both %s -DBYTECODE
+// RUN: %clang_cc1 -std=c++2c -verify=ref,both %s
typedef __INT64_TYPE__ int64_t;
namespace std {
@@ -239,7 +239,7 @@ namespace records {
/// Destructor is NOT called.
struct A {
bool b;
- constexpr ~A() { if (b) throw; }
+ constexpr ~A() { if (b) __builtin_abort(); }
};
constexpr int foo() {
More information about the cfe-commits
mailing list