Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -14557,7 +14557,9 @@ // Note that we use the C++11 definition everywhere because nothing in // C++03 depends on whether we get the C++03 version correct. The second // part does not apply to references, since they are not objects. - if (OdrUseContext && E && + bool InitIsValueDependent = + Var->hasInit() && Var->getInit()->isValueDependent(); + if (OdrUseContext && E && !InitIsValueDependent && IsVariableAConstantExpression(Var, SemaRef.Context)) { // A reference initialized by a constant expression can never be // odr-used, so simply ignore it. Index: test/SemaCXX/cxx11-odr-use-crash-on-invalid.cpp =================================================================== --- /dev/null +++ test/SemaCXX/cxx11-odr-use-crash-on-invalid.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// Don't crash due to the 'c :' as the return type of d. + +template +int b() {} +template +c : d() { // expected-error {{unexpected ':'}} \ + // expected-error {{nested name specifier 'c::' for declaration does not refer}} + c &e = b; + auto i = e; +}