Improve error message when referencing a non-tag type with a tag
authorReid Kleckner <rnk@google.com>
Fri, 9 Dec 2016 19:47:58 +0000 (19:47 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 9 Dec 2016 19:47:58 +0000 (19:47 +0000)
commit1a4ab7e77278f0dcb827451d54a47d6d272f8282
tree1f9ca1855cad9ac3e247e6ac2ab06573abe3437c
parentf0e87cf2c3dd9c45906fdc84eaae5e577dfb9829
Improve error message when referencing a non-tag type with a tag

Other compilers accept invalid code here that we reject, and we need a
better error message to try to convince users that the code is really
incorrect. Consider:
  class Foo {
    typedef MyIterHelper<Foo> iterator;
    friend class iterator;
  };

Previously our wording was "elaborated type refers to a typedef".
"elaborated type" isn't widely known terminology, so the new diagnostic
says "typedef 'iterator' cannot be referenced with class specifier".

Reviewers: rsmith

Differential Revision: https://reviews.llvm.org/D25216

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