rnk updated this revision to Diff 79805.
rnk added a comment.

- rebase


https://reviews.llvm.org/D25216

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/TreeTransform.h
  test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
  test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
  test/CXX/drs/dr2xx.cpp
  test/CXX/drs/dr4xx.cpp
  test/CXX/temp/temp.decls/temp.friend/p1.cpp
  test/CXX/temp/temp.spec/no-body.cpp
  test/SemaCXX/PR8755.cpp
  test/SemaCXX/using-decl-templates.cpp
  test/SemaTemplate/template-id-expr.cpp

Index: test/SemaTemplate/template-id-expr.cpp
===================================================================
--- test/SemaTemplate/template-id-expr.cpp
+++ test/SemaTemplate/template-id-expr.cpp
@@ -100,5 +100,5 @@
 class C {};
 template <template <typename> class D>  // expected-note{{previous use is here}}
 class E {
-  template class D<C>;  // expected-error {{elaborated type refers to a template template argument}}
+  template class D<C>;  // expected-error {{'D' is a template template argument that cannot be referenced with a class tag}}
 };
Index: test/SemaCXX/using-decl-templates.cpp
===================================================================
--- test/SemaCXX/using-decl-templates.cpp
+++ test/SemaCXX/using-decl-templates.cpp
@@ -90,7 +90,7 @@
   template<typename T> struct A { };
   template<typename T> using APtr = A<T*>; // expected-note{{previous use is here}}
 
-  template struct APtr<int>; // expected-error{{elaborated type refers to a type alias template}}
+  template struct APtr<int>; // expected-error{{'APtr' is a type alias template that cannot be referenced with a struct tag}}
 }
 
 namespace DontDiagnoseInvalidTest {
Index: test/SemaCXX/PR8755.cpp
===================================================================
--- test/SemaCXX/PR8755.cpp
+++ test/SemaCXX/PR8755.cpp
@@ -7,7 +7,7 @@
 
 template <typename T>
 void f() {
-  class A <T> ::iterator foo;  // expected-error{{elaborated type refers to a typedef}}
+  class A <T> ::iterator foo;  // expected-error{{'iterator' is a typedef that cannot be referenced with a class tag}}
 }
 
 void g() {
Index: test/CXX/temp/temp.spec/no-body.cpp
===================================================================
--- test/CXX/temp/temp.spec/no-body.cpp
+++ test/CXX/temp/temp.spec/no-body.cpp
@@ -43,7 +43,7 @@
 
 namespace unsupported {
 #ifndef FIXING
- template struct y;     // expected-error {{elaborated type refers to a template}}
+ template struct y;     // expected-error {{'y' is a template that cannot be referenced with a struct tag}}
 #endif
 }
 
Index: test/CXX/temp/temp.decls/temp.friend/p1.cpp
===================================================================
--- test/CXX/temp/temp.decls/temp.friend/p1.cpp
+++ test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -174,7 +174,7 @@
 
   // This shouldn't crash.
   template <class T> class D {
-    friend class A; // expected-error {{elaborated type refers to a template}}
+    friend class A; // expected-error {{'A' is a template that cannot be referenced with a class tag}}
   };
   template class D<int>;
 }
Index: test/CXX/drs/dr4xx.cpp
===================================================================
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -90,7 +90,7 @@
     struct S *p;
     {
       typedef struct S S; // expected-note {{here}}
-      struct S *p; // expected-error {{refers to a typedef}}
+      struct S *p; // expected-error {{'S' is a typedef}}
     }
   }
   struct S {};
Index: test/CXX/drs/dr2xx.cpp
===================================================================
--- test/CXX/drs/dr2xx.cpp
+++ test/CXX/drs/dr2xx.cpp
@@ -620,7 +620,7 @@
   template<typename T> struct A {
     typedef typename T::type type; // ok even if this is a typedef-name, because
                                    // it's not an elaborated-type-specifier
-    typedef struct T::type foo; // expected-error {{elaborated type refers to a typedef}}
+    typedef struct T::type foo; // expected-error {{'type' is a typedef that cannot be referenced with a struct tag}}
   };
   struct B { struct type {}; };
   struct C { typedef struct {} type; }; // expected-note {{here}}
@@ -1037,8 +1037,8 @@
   C::type i3;
 
   struct A a;
-  struct B b; // expected-error {{refers to a typedef}}
-  struct C c; // expected-error {{refers to a typedef}}
+  struct B b; // expected-error {{'B' is a typedef}}
+  struct C c; // expected-error {{'C' is a typedef}}
 
   B::B() {} // expected-error {{requires a type specifier}}
   B::A() {} // ok
Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
===================================================================
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
@@ -2,18 +2,18 @@
 
 struct A { typedef int type; };
 template<typename T> using X = A; // expected-note {{declared here}}
-struct X<int>* p2; // expected-error {{elaborated type refers to a type alias template}}
+struct X<int>* p2; // expected-error {{'X' is a type alias template that cannot be referenced with a struct tag}}
 
 
 template<typename T> using Id = T; // expected-note {{declared here}}
 template<template<typename> class F>
 struct Y {
-  struct F<int> i; // expected-error {{elaborated type refers to a type alias template}}
+  struct F<int> i; // expected-error {{'Id' is a type alias template that cannot be referenced with a struct tag}}
   typename F<A>::type j; // ok
 
   // FIXME: don't produce the diagnostic both for the definition and the instantiation.
   template<typename T> using U = F<char>; // expected-note 2{{declared here}}
-  struct Y<F>::template U<char> k; // expected-error 2{{elaborated type refers to a type alias template}}
+  struct Y<F>::template U<char> k; // expected-error 2{{'U' is a type alias template that cannot be referenced with a struct tag}}
   typename Y<F>::template U<char> l; // ok
 };
 template struct Y<Id>; // expected-note {{requested here}}
Index: test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
===================================================================
--- test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
+++ test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
@@ -9,16 +9,16 @@
     typedef int A; // expected-note {{declared here}}
 
     int test() {
-      struct A a; // expected-error {{elaborated type refers to a typedef}}
+      struct A a; // expected-error {{'A' is a typedef that cannot be referenced with a struct tag}}
       return a.foo;
     }
   }
 
   namespace i1 {
     template <class> class A; // expected-note {{declared here}}
 
     int test() {
-      struct A a; // expected-error {{elaborated type refers to a template}}
+      struct A a; // expected-error {{'A' is a template that cannot be referenced with a struct tag}}
       return a.foo;
     }
   }
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -1014,7 +1014,8 @@
         case LookupResult::FoundUnresolvedValue: {
           NamedDecl *SomeDecl = Result.getRepresentativeDecl();
           Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl);
-          SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << NTK;
+          SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << SomeDecl
+                                                               << NTK << Kind;
           SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
           break;
         }
@@ -5706,7 +5707,8 @@
               Template.getAsTemplateDecl())) {
         SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(),
                      diag::err_tag_reference_non_tag)
-            << Sema::NTK_TypeAliasTemplate;
+            << TAT << Sema::NTK_TypeAliasTemplate
+            << ElaboratedType::getTagTypeKindForKeyword(T->getKeyword());
         SemaRef.Diag(TAT->getLocation(), diag::note_declared_at);
       }
     }
Index: lib/Sema/SemaTemplate.cpp
===================================================================
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2489,7 +2489,8 @@
     //   If the identifier resolves to a typedef-name or the simple-template-id
     //   resolves to an alias template specialization, the
     //   elaborated-type-specifier is ill-formed.
-    Diag(TemplateLoc, diag::err_tag_reference_non_tag) << NTK_TypeAliasTemplate;
+    Diag(TemplateLoc, diag::err_tag_reference_non_tag)
+        << TAT << NTK_TypeAliasTemplate << TagKind;
     Diag(TAT->getLocation(), diag::note_declared_at);
   }
   
@@ -7462,7 +7463,7 @@
 
   if (!ClassTemplate) {
     NonTagKind NTK = getNonTagTypeDeclKind(TD);
-    Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << NTK;
+    Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK << Kind;
     Diag(TD->getLocation(), diag::note_previous_use);
     return true;
   }
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13205,7 +13205,7 @@
       if ((TUK == TUK_Reference || TUK == TUK_Friend) &&
           !Previous.isForRedeclaration()) {
         NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl);
-        Diag(NameLoc, diag::err_tag_reference_non_tag) << NTK;
+        Diag(NameLoc, diag::err_tag_reference_non_tag) << PrevDecl << NTK << Kind;
         Diag(PrevDecl->getLocation(), diag::note_declared_at);
         Invalid = true;
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -4553,7 +4553,9 @@
   "%select{typedef|type alias|type alias template}0 "
   "redefinition with different types%diff{ ($ vs $)|}1,2">;
 def err_tag_reference_non_tag : Error<
-  "elaborated type refers to %select{a non-tag type|a typedef|a type alias|a template|a type alias template|a template template argument}0">;
+  "%0 is a %select{non-tag type|typedef|type alias|template|type alias "
+  "template|template template argument}1 that cannot be referenced with a "
+  "%select{struct|interface|union|class|enum}2 tag">;
 def err_tag_reference_conflict : Error<
   "implicit declaration introduced by elaborated type conflicts with "
   "%select{a declaration|a typedef|a type alias|a template}0 of the same name">;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to