]> granicus.if.org Git - clang/commitdiff
Fix an infinite loop, caused by unintended syntax bug (the 'break;' after 'default...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 7 Oct 2010 21:52:18 +0000 (21:52 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 7 Oct 2010 21:52:18 +0000 (21:52 +0000)
Fixes rdar://8518859&8520617.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115985 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/SemaCXX/type-dependent-exprs.cpp

index e79b639229626e46607d04f7408d4801f00dc50a..ae2fef21c4e5c0a842f01487b73f9ff99622821e 100644 (file)
@@ -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();
index abe1b4d730cae33c601932c322ffb22596ef4842..37d7cee8816186a4a74b1d2dd303169640016a6e 100644 (file)
@@ -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}}
+}
+