OSDN Git Service

PR c++/13950
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Feb 2004 20:00:47 +0000 (20:00 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Feb 2004 20:00:47 +0000 (20:00 +0000)
* parser.c (cp_parser_class_name): Robustify.

PR c++/13970
* parser.c (cp_parser_cache_group): Do not consume the EOF token.

PR c++/13950
* g++.dg/template/lookup4.C: New test.

PR c++/13970
* g++.dg/parse/error14.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@77186 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/error14.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/lookup4.C [new file with mode: 0644]

index a4c9c81..7a398cb 100644 (file)
@@ -1,5 +1,11 @@
 2004-02-03  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/13950
+       * parser.c (cp_parser_class_name): Robustify.
+
+       PR c++/13970
+       * parser.c (cp_parser_cache_group): Do not consume the EOF token.
+
        PR c++/14002
        * semantics.c (finish_id_expression): Do not return an
        IDENTIFIER_NODE when lookup finds a PARM_DECL.
index 2857468..4905b94 100644 (file)
@@ -11622,8 +11622,11 @@ cp_parser_class_name (cp_parser *parser,
 
   /* If this is a typename, create a TYPENAME_TYPE.  */
   if (typename_p && decl != error_mark_node)
-    decl = TYPE_NAME (make_typename_type (scope, decl,
-                                         /*complain=*/1));
+    {
+      decl = make_typename_type (scope, decl, /*complain=*/1);
+      if (decl != error_mark_node)
+       decl = TYPE_NAME (decl);
+    }
 
   /* Check to see that it is really the name of a class.  */
   if (TREE_CODE (decl) == TEMPLATE_ID_EXPR 
@@ -15069,11 +15072,11 @@ cp_parser_cache_group (cp_parser *parser,
       if ((end == CPP_CLOSE_PAREN || depth == 0)
          && cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
        return;
-      /* Consume the next token.  */
-      token = cp_lexer_consume_token (parser->lexer);
       /* If we've reached the end of the file, stop.  */
-      if (token->type == CPP_EOF)
+      if (cp_lexer_next_token_is (parser->lexer, CPP_EOF))
        return;
+      /* Consume the next token.  */
+      token = cp_lexer_consume_token (parser->lexer);
       /* Add this token to the tokens we are saving.  */
       cp_token_cache_push_token (cache, token);
       /* See if it starts a new group.  */
index b08666a..00c0b71 100644 (file)
@@ -1,5 +1,11 @@
 2004-02-03  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/13950
+       * g++.dg/template/lookup4.C: New test.
+
+       PR c++/13970
+       * g++.dg/parse/error14.C: New test.
+
        PR c++/14002
        * g++.dg/parse/template13.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/parse/error14.C b/gcc/testsuite/g++.dg/parse/error14.C
new file mode 100644 (file)
index 0000000..4b23045
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/13970
+
+struct X
+{
+    template< typename Z > Z Zunc()
+    {
+        return Z();
+    }
+
+    template< typename Z > void Zinc()
+    {
+    }
+
+    void tst()
+    {
+        Zunc<int>();
+
+        Zinc<int>( //);
+                 //    }
+
+}; // { dg-error "" }
+
diff --git a/gcc/testsuite/g++.dg/template/lookup4.C b/gcc/testsuite/g++.dg/template/lookup4.C
new file mode 100644 (file)
index 0000000..d640061
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/13950
+
+template <class T> struct Base {};
+template <class T> struct Derived: public Base<T> {
+  typename Derived::template Base<double>* p1; // { dg-error "" }
+};