[clang] [clang][bytecode] Fix modify_global diagnostics in C++11 (PR #108358)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 12 03:49:31 PDT 2024
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/108358
We shouldn't emit this until C++14.
>From 82627320e5b3ec07f01d9f1761e5e871b1dc5919 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 12 Sep 2024 12:44:48 +0200
Subject: [PATCH] [clang][bytecode] Fix modify_global diagnostics in C++11
We shouldn't emit this until C++14.
---
clang/lib/AST/ByteCode/Interp.cpp | 2 +-
clang/test/AST/ByteCode/cxx11.cpp | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 2fa8b40f6085ad..827a177f9bf830 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -883,7 +883,7 @@ bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
return diagnoseUnknownDecl(S, OpPC, D);
assert(AK == AK_Assign);
- if (S.getLangOpts().CPlusPlus11) {
+ if (S.getLangOpts().CPlusPlus14) {
const SourceInfo &E = S.Current->getSource(OpPC);
S.FFDiag(E, diag::note_constexpr_modify_global);
}
diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp
index 481e3da9289efa..86b58283023bc8 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -169,3 +169,8 @@ namespace FinalLtorDiags {
A<q> c; // both-error {{non-type template argument of type 'int *' is not a constant expression}} \
// both-note {{read of non-constexpr variable 'q' is not allowed in a constant expression}}
}
+
+void lambdas() {
+ int d;
+ int a9[1] = {[d = 0] = 1}; // both-error {{not an integral constant expression}}
+}
More information about the cfe-commits
mailing list