re PR c++/84348 (ICE with invalid friend declaration)
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 19 Feb 2018 08:49:30 +0000 (08:49 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 19 Feb 2018 08:49:30 +0000 (08:49 +0000)
/cp
2018-02-19  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/84348
* decl.c (grokdeclarator): Early return error_mark_node upon
ill-formed friend declaration.

/testsuite
2018-02-19  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/84348
* g++.dg/cpp0x/auto50.C: New.
* g++.dg/parse/friend12.C: Adjust.

From-SVN: r257802

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/auto50.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/friend12.C

index 728c501..7ebd5ab 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-19  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84348
+       * decl.c (grokdeclarator): Early return error_mark_node upon
+       ill-formed friend declaration.
+
 2018-02-16  Marek Polacek  <polacek@redhat.com>
            Jakub Jelinek  <jakub@redhat.com>
 
index 15f7f12..f91f311 100644 (file)
@@ -12141,7 +12141,7 @@ grokdeclarator (const cp_declarator *declarator,
              {
                error ("%qE is neither function nor member function; "
                       "cannot be declared friend", unqualified_id);
-               friendp = 0;
+               return error_mark_node;
              }
            decl = NULL_TREE;
          }
index 5064357..c91b261 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-19  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84348
+       * g++.dg/cpp0x/auto50.C: New.
+       * g++.dg/parse/friend12.C: Adjust.
+
 2018-02-18  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/84389
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto50.C b/gcc/testsuite/g++.dg/cpp0x/auto50.C
new file mode 100644 (file)
index 0000000..814892d
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/84348
+// { dg-do compile { target c++11 } }
+
+template<typename> struct A
+{
+  friend auto foo;  // { dg-error "cannot be declared friend" }
+};
index 84d6e25..d4e0cee 100644 (file)
@@ -3,5 +3,4 @@
 struct A
 {
   friend int i = 0;  // { dg-error "cannot be declared friend" }
-// { dg-error "non-static data member" "" { target { ! c++11 } } .-1 }
 };