Index: lib/Sema/SemaStmt.cpp =================================================================== --- lib/Sema/SemaStmt.cpp +++ lib/Sema/SemaStmt.cpp @@ -399,7 +399,8 @@ QualType CondType = CondExpr->getType(); auto CheckAndFinish = [&](Expr *E) { - if (CondType->isDependentType() || E->isTypeDependent()) + if (CondType->isDependentType() || CondExpr->isInstantiationDependent() || + E->isTypeDependent()) return ExprResult(E); if (getLangOpts().CPlusPlus11) { @@ -690,7 +691,8 @@ Expr *CondExpr = Cond.get().second; assert((Cond.isInvalid() || CondExpr) && "switch with no condition"); - if (CondExpr && !CondExpr->isTypeDependent()) { + if (CondExpr && !CondExpr->isTypeDependent() && + !CondExpr->isInstantiationDependent()) { // We have already converted the expression to an integral or enumeration // type, when we parsed the switch condition. If we don't have an // appropriate type now, enter the switch scope but remember that it's Index: test/SemaTemplate/non-integral-switch-cond.cpp =================================================================== --- /dev/null +++ test/SemaTemplate/non-integral-switch-cond.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct NOT_AN_INTEGRAL_TYPE {}; + +template +struct foo { + NOT_AN_INTEGRAL_TYPE Bad; + void run() { + switch (Bad) { // expected-error {{statement requires expression of integer type ('NOT_AN_INTEGRAL_TYPE' invalid)}} + case 0: + break; + } + } +}; + +int main() { + foo instance; + instance.run(); // expected-note {{in instantiation of member function 'foo::run' requested here}} +}