]> granicus.if.org Git - clang/commitdiff
Handle redundant 'typename' on base class specifications.
authorDavid Blaikie <dblaikie@gmail.com>
Tue, 25 Oct 2011 18:46:41 +0000 (18:46 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 25 Oct 2011 18:46:41 +0000 (18:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142937 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseDeclCXX.cpp
test/CXX/class.derived/p1.cpp

index f8b54400e017f3289a9a0b3a6c57fea56fbd00ef..e0b10fa87c2c0f84a83566d6cc627c8dfaf64f8b 100644 (file)
@@ -252,6 +252,8 @@ def err_unexpected_typedef_ident : Error<
 def err_unexpected_scope_on_base_decltype : Error<
   "unexpected namespace scope prior to decltype">;
 def err_expected_class_name : Error<"expected class name">;
+def err_expected_class_name_not_template : 
+  Error<"'typename' is redundant; base classes are implicitly types">;
 def err_unspecified_vla_size_with_static : Error<
   "'static' may not be used with an unspecified variable length array size">;
 
index 8530ff2740a7bedec91d03a75650793d4535c4e5..1ba1cbfbd66df06c78c7b64f6337ef9cdc4b86ac 100644 (file)
@@ -713,6 +713,13 @@ void Parser::ParseUnderlyingTypeSpecifier(DeclSpec &DS) {
 ///
 Parser::TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
                                                   SourceLocation &EndLocation) {
+  // Ignore attempts to use typename
+  if (Tok.is(tok::kw_typename)) {
+    Diag(Tok, diag::err_expected_class_name_not_template)
+      << FixItHint::CreateRemoval(Tok.getLocation());
+    ConsumeToken();
+  }
+
   // Parse optional nested-name-specifier
   CXXScopeSpec SS;
   ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false);
index d819ea2389472ec7a0b8405dec1db5bccc773b60..dc5cb2b8c2a3890ae15bbb36513ab5d9dff5afb8 100644 (file)
@@ -34,4 +34,7 @@ namespace PR11216 {
   struct Derived4 : :: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
 
   struct Derived5 : PR11216:: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
+
+  template<typename T>
+  struct Derived6 : typename T::foo { }; // expected-error {{'typename' is redundant; base classes are implicitly types}}
 }