summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-08-08 01:50:23 +0000
committerRichard Trieu <rtrieu@google.com>2013-08-08 01:50:23 +0000
commit493df1a14f5dc5267a029c6ff58018efe0647297 (patch)
tree2f383d3265b034f2ae2cbe84fab473f2b768942a /clang/lib/Sema/SemaExpr.cpp
parentd25f7fc4aeca0c4a2ff66abc9d44f8875a178979 (diff)
downloadbcm5719-llvm-493df1a14f5dc5267a029c6ff58018efe0647297.tar.gz
bcm5719-llvm-493df1a14f5dc5267a029c6ff58018efe0647297.zip
Emit an error for enum increments and decrements in C++ mode.
Fixes PR16394. llvm-svn: 187955
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8038a4502ab..8515cb2f53f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8377,6 +8377,10 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
}
// Increment of bool sets it to true, but is deprecated.
S.Diag(OpLoc, diag::warn_increment_bool) << Op->getSourceRange();
+ } else if (S.getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
+ // Error on enum increments and decrements in C++ mode
+ S.Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
+ return QualType();
} else if (ResType->isRealType()) {
// OK!
} else if (ResType->isPointerType()) {
OpenPOWER on IntegriCloud