[clang] 6b380a8 - [clang][Interp] Fix integral overflow reporting
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 13 22:28:17 PDT 2024
Author: Timm Bäder
Date: 2024-07-14T07:28:01+02:00
New Revision: 6b380a810ea57fdb36ef911756bd2e1cbf2fbac0
URL: https://github.com/llvm/llvm-project/commit/6b380a810ea57fdb36ef911756bd2e1cbf2fbac0
DIFF: https://github.com/llvm/llvm-project/commit/6b380a810ea57fdb36ef911756bd2e1cbf2fbac0.diff
LOG: [clang][Interp] Fix integral overflow reporting
We need to always do the CCEDiag, the report() is optional.
Added:
Modified:
clang/lib/AST/Interp/Interp.h
clang/test/SemaCXX/enum.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 1df8d65c80445..95f89990a7a18 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -302,15 +302,16 @@ bool AddSubMulHelper(InterpState &S, CodePtr OpPC, unsigned Bits, const T &LHS,
auto Loc = E->getExprLoc();
S.report(Loc, diag::warn_integer_constant_overflow)
<< Trunc << Type << E->getSourceRange();
- return true;
- } else {
- S.CCEDiag(E, diag::note_constexpr_overflow) << Value << Type;
- if (!S.noteUndefinedBehavior()) {
- S.Stk.pop<T>();
- return false;
- }
- return true;
}
+
+ S.CCEDiag(E, diag::note_constexpr_overflow) << Value << Type;
+
+ if (!S.noteUndefinedBehavior()) {
+ S.Stk.pop<T>();
+ return false;
+ }
+
+ return true;
}
template <PrimType Name, class T = typename PrimConv<Name>::T>
diff --git a/clang/test/SemaCXX/enum.cpp b/clang/test/SemaCXX/enum.cpp
index 7d4a05083b9cd..739d35ec4a06b 100644
--- a/clang/test/SemaCXX/enum.cpp
+++ b/clang/test/SemaCXX/enum.cpp
@@ -1,5 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
+
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s -fexperimental-new-constant-interpreter
+
enum E { // expected-note{{previous definition is here}}
Val1,
Val2
More information about the cfe-commits
mailing list