Commit 48b6cd9d by Simon Martin Committed by H.J. Lu

re PR c++/37647 (ICE with invalid use of constructor)

gcc/cp/

2009-03-27  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/37647
	* decl.c (grokdeclarator): Reject [con|de]stuctors in a non-class
	scope.

gcc/testsuite/

2009-03-27  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/37647
	* g++.dg/parse/ctor9.C: New test.

From-SVN: r145105
parent 6a837908
2009-03-27 Simon Martin <simartin@users.sourceforge.net>
PR c++/37647
* decl.c (grokdeclarator): Reject [con|de]stuctors in a non-class
scope.
2009-03-27 Simon Martin <simartin@users.sourceforge.net>
PR c++/29727
* decl.c (check_array_designated_initializer): Handle error_mark_node.
......
......@@ -9346,6 +9346,14 @@ grokdeclarator (const cp_declarator *declarator,
error ("virtual non-class function %qs", name);
virtualp = 0;
}
else if (sfk == sfk_constructor
|| sfk == sfk_destructor)
{
error (funcdef_flag
? "%qs defined in a non-class scope"
: "%qs declared in a non-class scope", name);
sfk = sfk_none;
}
}
else if (TREE_CODE (type) == FUNCTION_TYPE && staticp < 2
&& !NEW_DELETE_OPNAME_P (original_name))
......
2009-03-27 Simon Martin <simartin@users.sourceforge.net>
PR c++/37647
* g++.dg/parse/ctor9.C: New test.
2009-03-27 Simon Martin <simartin@users.sourceforge.net>
PR c++/29727
* g++.dg/init/error2.C: New test.
......
/* PR c++/37647 */
/* { dg-do "compile" } */
struct A
{
A() { void A(); } /* { dg-error "return type specification for constructor invalid|non-class scope" } */
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment