diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -2034,11 +2034,13 @@ ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, /*DiagnoseEmptyAttrs=*/true); - TagOrTempResult = Actions.ActOnTemplatedFriendTag( - getCurScope(), DS.getFriendSpecLoc(), TagType, StartLoc, SS, Name, - NameLoc, attrs, - MultiTemplateParamsArg(TemplateParams ? &(*TemplateParams)[0] : nullptr, - TemplateParams ? TemplateParams->size() : 0)); + if (auto *FT = Actions.ActOnTemplatedFriendTag( + getCurScope(), DS.getFriendSpecLoc(), TagType, StartLoc, SS, Name, + NameLoc, attrs, + MultiTemplateParamsArg( + TemplateParams ? &(*TemplateParams)[0] : nullptr, + TemplateParams ? TemplateParams->size() : 0))) + TagOrTempResult = FT; } else { if (TUK != Sema::TUK_Declaration && TUK != Sema::TUK_Definition) ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed, @@ -2066,14 +2068,15 @@ stripTypeAttributesOffDeclSpec(attrs, DS, TUK); // Declaration or definition of a class type - TagOrTempResult = Actions.ActOnTag( - getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS, - DS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent, - SourceLocation(), false, clang::TypeResult(), - DSC == DeclSpecContext::DSC_type_specifier, - DSC == DeclSpecContext::DSC_template_param || - DSC == DeclSpecContext::DSC_template_type_arg, - OffsetOfState, &SkipBody); + if (auto *TagDecl = Actions.ActOnTag( + getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS, + DS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent, + SourceLocation(), false, clang::TypeResult(), + DSC == DeclSpecContext::DSC_type_specifier, + DSC == DeclSpecContext::DSC_template_param || + DSC == DeclSpecContext::DSC_template_type_arg, + OffsetOfState, &SkipBody)) + TagOrTempResult = TagDecl; // If ActOnTag said the type was dependent, try again with the // less common call. diff --git a/clang/test/Parser/cxx-undeclared-identifier.cpp b/clang/test/Parser/cxx-undeclared-identifier.cpp --- a/clang/test/Parser/cxx-undeclared-identifier.cpp +++ b/clang/test/Parser/cxx-undeclared-identifier.cpp @@ -15,5 +15,5 @@ // PR7180 int f(a::b::c); // expected-error {{use of undeclared identifier 'a'}} -class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}} \ - // expected-error {{expected ';' after class}} +class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}} + // expected-error {{expected unqualified-id}} diff --git a/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp --- a/clang/test/Parser/recovery.cpp +++ b/clang/test/Parser/recovery.cpp @@ -212,6 +212,6 @@ enum ::, enum ::; // expected-error 2 {{expected identifier}} struct ::__super, struct ::__super; // expected-error 2 {{expected identifier}} expected-error 2 {{expected '::' after '__super'}} struct ::template foo, struct ::template bar; // expected-error 2 {{expected identifier}} expected-error 2 {{declaration of anonymous struct must be a definition}} expected-warning {{declaration does not declare anything}} -struct ::foo struct::; // expected-error {{no struct named 'foo' in the global namespace}} expected-error {{expected identifier}} expected-error {{declaration of anonymous struct must be a definition}} +struct ::foo struct::; // expected-error {{no struct named 'foo' in the global namespace}} expected-error {{expected identifier}} class :: : {} a; // expected-error {{expected identifier}} expected-error {{expected class name}} } diff --git a/clang/test/SemaCXX/invalid-template-params.cpp b/clang/test/SemaCXX/invalid-template-params.cpp --- a/clang/test/SemaCXX/invalid-template-params.cpp +++ b/clang/test/SemaCXX/invalid-template-params.cpp @@ -15,9 +15,8 @@ public: template' in template-parameter-list}} - // expected-error@-3 {{declaration does not declare anything}} + // expected-error@-1 {{expected ',' or '>' in template-parameter-list}} + // expected-error@-2 {{declaration does not declare anything}} C0() : m(new S0) {} // expected-error {{expected '(' for function-style cast or type construction}} // expected-error@-1 {{expected expression}} S0 *m; // expected-error {{expected member name or ';' after declaration specifiers}} diff --git a/clang/test/SemaCXX/rdar42746401.cpp b/clang/test/SemaCXX/rdar42746401.cpp --- a/clang/test/SemaCXX/rdar42746401.cpp +++ b/clang/test/SemaCXX/rdar42746401.cpp @@ -4,4 +4,4 @@ class b; class c; // expected-note{{forward declaration}} -::b<0> struct c::d // expected-error{{incomplete type}} expected-error{{cannot combine}} expected-error{{expected unqualified-id}} +::b<0> struct c::d // expected-error{{incomplete type}} expected-error{{expected unqualified-id}}