[clang] f22a8d1 - [clang][bytecode] Fix modify_global diagnostics in C++11 (#108358)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 12 04:25:29 PDT 2024
Author: Timm Baeder
Date: 2024-09-12T13:25:25+02:00
New Revision: f22a8d18229fe94fe340afbf02ad9592ca199784
URL: https://github.com/llvm/llvm-project/commit/f22a8d18229fe94fe340afbf02ad9592ca199784
DIFF: https://github.com/llvm/llvm-project/commit/f22a8d18229fe94fe340afbf02ad9592ca199784.diff
LOG: [clang][bytecode] Fix modify_global diagnostics in C++11 (#108358)
We shouldn't emit this until C++14.
Added:
Modified:
clang/lib/AST/ByteCode/Interp.cpp
clang/test/AST/ByteCode/cxx11.cpp
Removed:
################################################################################
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