re PR c++/34488 (ICE on invalid friend declaration)
PR c++/34488 * decl.c (grokdeclarator): Reject friend sfk_constructor FUNCTION_TYPE. * g++.dg/parse/friend7.C: New test. From-SVN: r131025
This commit is contained in:
parent
dc7c279e97
commit
ac3b1156b1
@ -1,3 +1,9 @@
|
||||
2007-12-18 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/34488
|
||||
* decl.c (grokdeclarator): Reject friend sfk_constructor
|
||||
FUNCTION_TYPE.
|
||||
|
||||
2007-12-17 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c/34506
|
||||
|
@ -8818,6 +8818,13 @@ grokdeclarator (const cp_declarator *declarator,
|
||||
return error_mark_node;
|
||||
}
|
||||
}
|
||||
else if (sfk == sfk_constructor && friendp)
|
||||
{
|
||||
error ("expected qualified name in friend declaration "
|
||||
"for constructor %qD",
|
||||
id_declarator->u.id.unqualified_name);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
/* Tell grokfndecl if it needs to set TREE_PUBLIC on the node. */
|
||||
function_context = (ctype != NULL_TREE) ?
|
||||
|
@ -1,5 +1,8 @@
|
||||
2007-12-18 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/34488
|
||||
* g++.dg/parse/friend7.C: New test.
|
||||
|
||||
PR rtl-optimization/34490
|
||||
* gcc.c-torture/execute/20071216-1.c: New test.
|
||||
|
||||
|
37
gcc/testsuite/g++.dg/parse/friend7.C
Normal file
37
gcc/testsuite/g++.dg/parse/friend7.C
Normal file
@ -0,0 +1,37 @@
|
||||
// PR c++/34488
|
||||
// { dg-do compile }
|
||||
|
||||
struct A
|
||||
{
|
||||
A ();
|
||||
~A ();
|
||||
A (const A &);
|
||||
};
|
||||
|
||||
struct B
|
||||
{
|
||||
friend A::A ();
|
||||
friend A::~A ();
|
||||
friend A::A (const A &);
|
||||
};
|
||||
|
||||
struct C
|
||||
{
|
||||
friend int C (); // { dg-error "return type|in friend decl" }
|
||||
friend int ~C (); // { dg-error "return type|in friend decl" }
|
||||
friend int C (const C &); // { dg-error "return type|in friend decl" }
|
||||
};
|
||||
|
||||
struct D
|
||||
{
|
||||
friend int D () {} // { dg-error "return type|in friend decl" }
|
||||
friend int ~D () {} // { dg-error "return type|in friend decl" }
|
||||
friend int D (const D &) {} // { dg-error "return type|in friend decl" }
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
friend A::A () {} // { dg-error "cannot define member" }
|
||||
friend A::~A () {} // { dg-error "cannot define member" }
|
||||
friend A::A (const A &) {} // { dg-error "cannot define member" }
|
||||
};
|
Loading…
Reference in New Issue
Block a user