Hi,

avoid crashing later in build_this_parm during error recovery. Tested x86_64-linux.

Thanks,
Paolo.

//////////////////
/cp
2014-12-15  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58650
        * decl.c (grokdeclarator): Avoid crashing on an initialized
        non-static data member wrongly declared friend.

/testsuite
2014-12-15  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58650
        * g++.dg/parse/friend12.C: New.
Index: cp/decl.c
===================================================================
--- cp/decl.c   (revision 218764)
+++ cp/decl.c   (working copy)
@@ -10803,6 +10803,7 @@ grokdeclarator (const cp_declarator *declarator,
                error ("%qE is neither function nor member function; "
                       "cannot be declared friend", unqualified_id);
                friendp = 0;
+               type = error_mark_node;
              }
            decl = NULL_TREE;
          }
Index: testsuite/g++.dg/parse/friend12.C
===================================================================
--- testsuite/g++.dg/parse/friend12.C   (revision 0)
+++ testsuite/g++.dg/parse/friend12.C   (working copy)
@@ -0,0 +1,7 @@
+// PR c++/58650
+
+struct A
+{
+  friend int i = 0;  // { dg-error "cannot be declared friend" }
+// { dg-error "non-static data member" "" { target { ! c++11 } } 5 }
+};

Reply via email to