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
+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>
PR c++/36254
2009-01-11 Jakub Jelinek <jakub@redhat.com>
PR c++/36254
/* Process declarations and variables for C++ compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
/* Process declarations and variables for C++ compiler.
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.
Contributed by Michael Tiemann (tiemann@cygnus.com)
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
tree decl1;
decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs);
tree decl1;
decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs);
+ if (decl1 == error_mark_node)
+ return 0;
/* If the declarator is not suitable for a function definition,
cause a syntax error. */
if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL)
/* If the declarator is not suitable for a function definition,
cause a syntax error. */
if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL)
+ {
+ error ("invalid function declaration");
+ return 0;
+ }
if (DECL_MAIN_P (decl1))
/* main must return int. grokfndecl should have corrected it
if (DECL_MAIN_P (decl1))
/* 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
* gcc.c-torture/compile/pr38807.c: New test.
PR tree-optimization/38807
* gcc.c-torture/compile/pr38807.c: New test.
--- /dev/null
+// 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" }
+};