[cfe-commits] r115985 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaCXX/type-dependent-exprs.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Oct 7 14:52:18 PDT 2010
Author: akirtzidis
Date: Thu Oct 7 16:52:18 2010
New Revision: 115985
URL: http://llvm.org/viewvc/llvm-project?rev=115985&view=rev
Log:
Fix an infinite loop, caused by unintended syntax bug (the 'break;' after 'default:' was intended to break out of the while loop).
Fixes rdar://8518859&8520617.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/type-dependent-exprs.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=115985&r1=115984&r2=115985&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Oct 7 16:52:18 2010
@@ -2454,14 +2454,10 @@
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();
Modified: cfe/trunk/test/SemaCXX/type-dependent-exprs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-dependent-exprs.cpp?rev=115985&r1=115984&r2=115985&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/type-dependent-exprs.cpp (original)
+++ cfe/trunk/test/SemaCXX/type-dependent-exprs.cpp Thu Oct 7 16:52:18 2010
@@ -22,3 +22,14 @@
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}}
+}
+
More information about the cfe-commits
mailing list