re PR c++/84348 (ICE with invalid friend declaration)

/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
This commit is contained in:
Paolo Carlini 2018-02-19 08:49:30 +00:00 committed by Paolo Carlini
parent 9f88a07b85
commit 50dbbe5357
5 changed files with 20 additions and 2 deletions

View 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>

View 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;
}

View 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

View File

@ -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" }
};

View 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 }
};