Skip to content

Commit 6b380a8

Browse files
committed
[clang][Interp] Fix integral overflow reporting
We need to always do the CCEDiag, the report() is optional.
1 parent 78bc1b6 commit 6b380a8

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

clang/lib/AST/Interp/Interp.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,16 @@ bool AddSubMulHelper(InterpState &S, CodePtr OpPC, unsigned Bits, const T &LHS,
302302
auto Loc = E->getExprLoc();
303303
S.report(Loc, diag::warn_integer_constant_overflow)
304304
<< Trunc << Type << E->getSourceRange();
305-
return true;
306-
} else {
307-
S.CCEDiag(E, diag::note_constexpr_overflow) << Value << Type;
308-
if (!S.noteUndefinedBehavior()) {
309-
S.Stk.pop<T>();
310-
return false;
311-
}
312-
return true;
313305
}
306+
307+
S.CCEDiag(E, diag::note_constexpr_overflow) << Value << Type;
308+
309+
if (!S.noteUndefinedBehavior()) {
310+
S.Stk.pop<T>();
311+
return false;
312+
}
313+
314+
return true;
314315
}
315316

316317
template <PrimType Name, class T = typename PrimConv<Name>::T>

clang/test/SemaCXX/enum.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s
22
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
3+
4+
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s -fexperimental-new-constant-interpreter
5+
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s -fexperimental-new-constant-interpreter
6+
37
enum E { // expected-note{{previous definition is here}}
48
Val1,
59
Val2

0 commit comments

Comments
 (0)