aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaChecking.cpp10
-rw-r--r--test/SemaCXX/type-dependent-exprs.cpp11
2 files changed, 14 insertions, 7 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index e79b639229..ae2fef21c4 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -2454,14 +2454,10 @@ static bool IsZero(Sema &S, Expr *E) {
static bool HasEnumType(Expr *E) {
// Strip off implicit integral promotions.
while (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
- switch (ICE->getCastKind()) {
- case CK_IntegralCast:
- case CK_NoOp:
- E = ICE->getSubExpr();
- continue;
- default:
+ if (ICE->getCastKind() != CK_IntegralCast &&
+ ICE->getCastKind() != CK_NoOp)
break;
- }
+ E = ICE->getSubExpr();
}
return E->getType()->isEnumeralType();
diff --git a/test/SemaCXX/type-dependent-exprs.cpp b/test/SemaCXX/type-dependent-exprs.cpp
index abe1b4d730..37d7cee881 100644
--- a/test/SemaCXX/type-dependent-exprs.cpp
+++ b/test/SemaCXX/type-dependent-exprs.cpp
@@ -22,3 +22,14 @@ T f(T x) {
h(1); // expected-error{{use of undeclared identifier 'h'}}
return 0;
}
+
+// This one entered into an infinite loop.
+template <unsigned long N>
+void rdar8520617() {
+ if (N > 1) { } // expected-warning {{comparison of 0 > unsigned expression is always false}}
+}
+
+int f2() {
+ rdar8520617<0>(); // expected-note {{in instantiation}}
+}
+