Commit 49f098f2 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/38794 (Function body accepted in typedef)

	PR c++/38794
	* decl.c (start_function): If grokdeclarator hasn't returned
	FUNCTION_DECL nor error_mark_node, issue diagnostics.

	* g++.dg/parse/typedef9.C: New test.

From-SVN: r143292
parent f56e675d
2009-01-12 Jakub Jelinek <jakub@redhat.com>
PR c++/38794
* decl.c (start_function): If grokdeclarator hasn't returned
FUNCTION_DECL nor error_mark_node, issue diagnostics.
2009-01-11 Jakub Jelinek <jakub@redhat.com> 2009-01-11 Jakub Jelinek <jakub@redhat.com>
PR c++/36254 PR c++/36254
......
/* Process declarations and variables for C++ compiler. /* Process declarations and variables for C++ compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc. Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com) Contributed by Michael Tiemann (tiemann@cygnus.com)
...@@ -11774,10 +11774,15 @@ start_function (cp_decl_specifier_seq *declspecs, ...@@ -11774,10 +11774,15 @@ start_function (cp_decl_specifier_seq *declspecs,
tree decl1; tree decl1;
decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs); decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs);
if (decl1 == error_mark_node)
return 0;
/* If the declarator is not suitable for a function definition, /* If the declarator is not suitable for a function definition,
cause a syntax error. */ cause a syntax error. */
if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL)
return 0; {
error ("invalid function declaration");
return 0;
}
if (DECL_MAIN_P (decl1)) if (DECL_MAIN_P (decl1))
/* main must return int. grokfndecl should have corrected it /* main must return int. grokfndecl should have corrected it
......
2009-01-12 Jakub Jelinek <jakub@redhat.com> 2009-01-12 Jakub Jelinek <jakub@redhat.com>
PR c++/38794
* g++.dg/parse/typedef9.C: New test.
PR tree-optimization/38807 PR tree-optimization/38807
* gcc.c-torture/compile/pr38807.c: New test. * gcc.c-torture/compile/pr38807.c: New test.
......
// PR c++/38794
// { dg-do compile }
typedef void foo () {} // { dg-error "invalid function declaration" }
struct S
{
typedef int bar (void) { return 0; } // { dg-error "invalid member function declaration" }
};
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