|
@@ -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.
|