Index: lib/Parse/ParseDecl.cpp =================================================================== --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -2616,12 +2616,13 @@ // and attempt to recover. ParsedType T; IdentifierInfo *II = Tok.getIdentifierInfo(); + bool isCPPAndMSCompat = getLangOpts().CPlusPlus && getLangOpts().MSVCCompat; bool IsTemplateName = - ((getLangOpts().CPlusPlus && NextToken().is(tok::less)) || - (SS && !SS->isEmpty() && - (DSC != DeclSpecContext::DSC_class && - DSC != DeclSpecContext::DSC_top_level) && - (NextToken().is(tok::amp) || NextToken().is(tok::star)))); + ((isCPPAndMSCompat && NextToken().is(tok::less)) || + (SS && SS->isSet() && !SS->isEmpty() && + ((NextToken().is(tok::amp) || NextToken().is(tok::ampamp) || + NextToken().is(tok::star)) && + GetLookAheadToken(2).isNot(tok::identifier)))); Actions.DiagnoseUnknownTypeName(II, Loc, getCurScope(), SS, T, IsTemplateName); if (T) { Index: lib/Parse/ParseTentative.cpp =================================================================== --- lib/Parse/ParseTentative.cpp +++ lib/Parse/ParseTentative.cpp @@ -1424,7 +1424,9 @@ *HasMissingTypename = true; return TPResult::Ambiguous; } - if (Tok.is(tok::amp) || Tok.is(tok::star)) + if (((Tok.is(tok::amp) || Tok.is(tok::star)) && + NextToken().isNot(tok::identifier)) || + (Tok.is(tok::ampamp) && NextToken().is(tok::greater))) return TPResult::True; // FIXME: Fails to either revert or commit the tentative parse! Index: test/SemaCXX/invalid-member-expr.cpp =================================================================== --- test/SemaCXX/invalid-member-expr.cpp +++ test/SemaCXX/invalid-member-expr.cpp @@ -53,7 +53,7 @@ namespace rdar11293995 { struct Length { - explicit Length(PassRefPtr); // expected-error {{no template named 'PassRefPtr}} expected-error {{undeclared identifier 'CalculationValue'}} + explicit Length(PassRefPtr); // expected-error {{unknown type name 'PassRefPtr'}} expected-error {{expected ')'}} expected-note {{to match this '('}} }; struct LengthSize { Index: test/SemaCXX/typo-correction.cpp =================================================================== --- test/SemaCXX/typo-correction.cpp +++ test/SemaCXX/typo-correction.cpp @@ -521,17 +521,17 @@ PR18685::BitVector Map; // expected-error-re {{no type named 'BitVector' in namespace 'PR18685'{{$}}}} namespace shadowed_template { -template class Fizbin {}; // expected-note {{'::shadowed_template::Fizbin' declared here}} +template class Fizbin {}; class Baz { int Fizbin(); - Fizbin qux; // expected-error {{no template named 'Fizbin'; did you mean '::shadowed_template::Fizbin'?}} + Fizbin qux; // expected-error {{unknown type name 'Fizbin'}} expected-error {{expected member name or ';' after declaration specifiers}} }; } namespace no_correct_template_id_to_non_template { struct Frobnatz {}; // expected-note {{declared here}} Frobnats fn; // expected-error {{unknown type name 'Frobnats'; did you mean 'Frobnatz'?}} - Frobnats fni; // expected-error-re {{no template named 'Frobnats'{{$}}}} + Frobnats fni; // expected-error {{unknown type name 'Frobnats'}} expected-error {{expected unqualified-id}} } namespace PR18852 { Index: test/SemaTemplate/deduction-crash.cpp =================================================================== --- test/SemaTemplate/deduction-crash.cpp +++ test/SemaTemplate/deduction-crash.cpp @@ -19,7 +19,7 @@ template struct state_machine { - typedef aaa::ae aaa; + typedef aaa::ae aaa; // expected-error {{no type named 'ae' in 'aaa'}} int start() { ant(0); Index: test/SemaTemplate/explicit-instantiation.cpp =================================================================== --- test/SemaTemplate/explicit-instantiation.cpp +++ test/SemaTemplate/explicit-instantiation.cpp @@ -95,7 +95,7 @@ struct basic_streambuf; template - struct basic_streambuf{friend bob<>()}; // expected-error{{no template named 'bob'}} \ + struct basic_streambuf{friend bob<>()}; // expected-error{{unknown type name 'bob'}} \ // expected-error{{expected member name or ';' after declaration specifiers}} template struct basic_streambuf; } Index: test/SemaTemplate/missing-typename.cpp =================================================================== --- test/SemaTemplate/missing-typename.cpp +++ test/SemaTemplate/missing-typename.cpp @@ -2,6 +2,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused -fms-compatibility -DMSVC // expected-no-diagnostics +namespace PR8446_1 { struct A { typedef int BASE_VALUE; }; @@ -16,8 +17,11 @@ int main() { int x; f(x); + return 0; } +} // namespace PR8446_1 +namespace PR8446_2 { struct site_symmetry_ops {}; template @@ -53,3 +57,16 @@ void wrap_special_position() { special_position_wrapper::wrap("special_position_site_parameter"); } +} // namespace PR8446_2 + +namespace PR8446_3 { +int g(int); +template +int f(int x) { + return g((T::InnerName & x) & x); +} +struct A { static const int InnerName = 42; }; +int main() { + return f(0); +} +} // namespace PR8446_3