OSDN Git Service

* decl.c (grokfndecl): Improve error-recovery.
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Sep 1998 11:58:41 +0000 (11:58 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Sep 1998 11:58:41 +0000 (11:58 +0000)
* decl2.c (grokfield): Likewise.
* pt.c (finish_member_template_decl): Likewise.

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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.other/friend4.C

index 6ccd3bf..360dcb0 100644 (file)
@@ -1,3 +1,9 @@
+1998-09-22  Mark Mitchell  <mark@markmitchell.com>
+
+       * decl.c (grokfndecl): Improve error-recovery.
+       * decl2.c (grokfield): Likewise.
+       * pt.c (finish_member_template_decl): Likewise.
+
 1998-09-20  Martin von Löwis  <loewis@informatik.hu-berlin.de>
 
        * method.c (hack_identifier): Finding multiple members is always
index ee094e5..17078e0 100644 (file)
@@ -7866,7 +7866,10 @@ bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises)
    or `volatile'.
    RAISES is a list of exceptions that this function can raise.
    CHECK is 1 if we must find this method in CTYPE, 0 if we should
-   not look, and -1 if we should not call `grokclassfn' at all.  */
+   not look, and -1 if we should not call `grokclassfn' at all.  
+
+   Returns `error_mark_node' if something goes wrong, after issuing
+   applicable error messages.  */
 
 static tree
 grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
@@ -8046,7 +8049,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
            return tmp;
        }
       if (! grok_ctor_properties (ctype, decl))
-       return NULL_TREE;
+       return error_mark_node;
 
       if (check == 0 && ! current_function_decl)
        {
@@ -10342,8 +10345,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                               virtualp, flags, quals, raises, attrlist,
                               friendp ? -1 : 0, friendp, publicp, inlinep,
                               funcdef_flag, template_count, in_namespace);
-           if (decl == NULL_TREE)
-             return NULL_TREE;
+           if (decl == NULL_TREE || decl == error_mark_node)
+             return decl;
 #if 0
            /* This clobbers the attrs stored in `decl' from `attrlist'.  */
            /* The decl and setting of decl_machine_attr is also turned off.  */
index be8689c..9d9e7ad 100644 (file)
@@ -1607,7 +1607,8 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
 
   value = grokdeclarator (declarator, declspecs, FIELD, init != 0, NULL_TREE);
   if (! value || value == error_mark_node)
-    return NULL_TREE; /* friend or constructor went bad.  */
+    /* friend or constructor went bad.  */
+    return value;
 
   /* Pass friendly classes back.  */
   if (TREE_CODE (value) == VOID_TYPE)
index de6794f..47cb0c3 100644 (file)
@@ -204,6 +204,10 @@ finish_member_template_decl (template_parameters, decl)
 
   if (decl == NULL_TREE || decl == void_type_node)
     return NULL_TREE;
+  else if (decl == error_mark_node)
+    /* By returning NULL_TREE, the parser will just ignore this
+       declaration.  We have already issued the error.  */
+    return NULL_TREE;
   else if (TREE_CODE (decl) == TREE_LIST)
     {
       /* Assume that the class is the only declspec.  */
@@ -229,7 +233,6 @@ finish_member_template_decl (template_parameters, decl)
     } 
   else
     cp_error ("invalid member template declaration `%D'", decl);
-       
 
   return error_mark_node;
 }
@@ -584,6 +587,7 @@ void
 check_specialization_scope ()
 {
   tree scope = current_scope ();
+
   /* [temp.expl.spec] 
      
      An explicit specialization shall be declared in the namespace of
@@ -596,6 +600,7 @@ check_specialization_scope ()
   if (scope && TREE_CODE (scope) != NAMESPACE_DECL)
     cp_error ("explicit specialization in non-namespace scope `%D'",
              scope);
+
   /* [temp.expl.spec] 
 
      In an explicit specialization declaration for a member of a class
index a208f5f..468340f 100644 (file)
 template <class A, class B> void foo();
 template <class C> class bar {
   int i;
-  template <class B> friend void foo<C,B>();
+  template <class B> friend void foo<C,B>(); // ERROR - bogus declaration
 };
 template <class A, class B> void foo() {
-  bar<A> baz; baz.i = 1;
-  bar<int> buz; buz.i = 1; // ERROR - foo<void,void> cannot access bar<int>::i - XFAIL *-*-*
+  bar<A> baz; baz.i = 1;   // ERROR - foo cannot access bar<int>::i
+  bar<int> buz; buz.i = 1; // ERROR - foo cannot access bar<int>::i
 }
 int main() {
   foo<void,void>();