aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 08f78d06ca..592c6a6b74 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -13,6 +13,7 @@
#include "clang/Sema/SemaInternal.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/EvaluatedExprVisitor.h"
@@ -725,7 +726,14 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
} else {
// We already verified that the expression has a i-c-e value (C99
// 6.8.4.2p3) - get that value now.
- LoVal = Lo->EvaluateKnownConstInt(Context);
+ llvm::SmallVector<PartialDiagnosticAt, 8> Diags;
+ LoVal = Lo->EvaluateKnownConstInt(Context, &Diags);
+ if (Diags.size() == 1 &&
+ Diags[0].second.getDiagID() == diag::note_constexpr_overflow) {
+ Diag(Lo->getLocStart(), diag::warn_case_value_overflow) <<
+ LoVal.toString(10) << "switch condition value";
+ Diag(Diags[0].first, Diags[0].second);
+ }
// If the LHS is not the same type as the condition, insert an implicit
// cast.