]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/13407 (Confusing error message from extraneous typename)
authorGiovanni Bajo <giovannibajo@gcc.gnu.org>
Fri, 16 Jan 2004 12:29:40 +0000 (12:29 +0000)
committerGiovanni Bajo <giovannibajo@gcc.gnu.org>
Fri, 16 Jan 2004 12:29:40 +0000 (12:29 +0000)
PR c++/13407
* parser.c (cp_parser_base_specifier): Check for an invalid
keyword 'typename' and emit an user-friendly error message.

From-SVN: r75969

gcc/cp/ChangeLog
gcc/cp/parser.c

index f78d9af6f230b546fa4d36c4a499d7d37accf7cb..a902c255768cc696d978bd0bd3b75631a20fcfb9 100644 (file)
@@ -1,3 +1,9 @@
+2004-01-15  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/13407
+       * parser.c (cp_parser_base_specifier): Check for an invalid
+       keyword `typename' and emit an user-friendly error message.
+
 2004-01-15  Geoffrey Keating  <geoffk@apple.com>
 
        PR pch/13361
index 6a78264421a8831f957d9afab004991c0d1173ac..481864b10955c1cd573f97a93803c4f0e7ede0ee 100644 (file)
@@ -12690,6 +12690,18 @@ cp_parser_base_specifier (cp_parser* parser)
          break;
        }
     }
+  /* It is not uncommon to see programs mechanically, errouneously, use\r
+     the 'typename' keyword to denote (dependent) qualified types\r
+     as base classes.  */
+  if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TYPENAME))
+    {
+      if (!processing_template_decl)
+       error ("keyword `typename' not allowed outside of templates");
+      else
+       error ("keyword `typename' not allowed in this context "
+              "(the base class is implicitly a type)");
+      cp_lexer_consume_token (parser->lexer);
+    }
 
   /* Look for the optional `::' operator.  */
   cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false);