aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-01-12 16:43:22 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-01-12 16:43:22 +0100
commit49f098f2566a36206d6aa17c2c4635b2bf8b8d80 (patch)
tree63c40fa8e8187caa4b08c713f55fd24395af7701 /gcc/cp
parentf56e675de51d00f2ddaede1933175374628f6952 (diff)
downloadgcc-49f098f2566a36206d6aa17c2c4635b2bf8b8d80.zip
gcc-49f098f2566a36206d6aa17c2c4635b2bf8b8d80.tar.gz
gcc-49f098f2566a36206d6aa17c2c4635b2bf8b8d80.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c9
2 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7b0c39f..de7d1ab 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 2e19fb3..c6ed22d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1,6 +1,6 @@
/* 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)
@@ -11774,10 +11774,15 @@ start_function (cp_decl_specifier_seq *declspecs,
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)
- return 0;
+ {
+ error ("invalid function declaration");
+ return 0;
+ }
if (DECL_MAIN_P (decl1))
/* main must return int. grokfndecl should have corrected it