aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-07-26 08:07:56 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-07-26 08:07:56 +0000
commit969fd501d60879e8cb717bc6be07ad39e5067f18 (patch)
treee75ee3f6066eb226d294e5a52b6c3511f4d79eff /gcc
parent4d10215152f92dd3ee79f114ba7dd6acc5e43b54 (diff)
downloadgcc-969fd501d60879e8cb717bc6be07ad39e5067f18.zip
gcc-969fd501d60879e8cb717bc6be07ad39e5067f18.tar.gz
gcc-969fd501d60879e8cb717bc6be07ad39e5067f18.tar.bz2
re PR c++/3152 (g++-3.0 segfaults when compiling program using -g)
cp: * decl.c (last_function_parm_tags): Remove. (current_function_parm_tags): Remove. (init_decl_processing): Adjust. (start_function): Adjust. (store_parm_decls): Adjust. PR c++/3152 * decl.c (grokdeclarator): Detect when a function typedef is declaring a function, and create last_function_parms correctly. testsuite: * g++.old-deja/g++.other/crash42.C: New test. From-SVN: r44387
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/decl.c35
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/crash42.C17
4 files changed, 54 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 050f437..70c9bd3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,15 @@
+2001-07-26 Nathan Sidwell <nathan@codesourcery.com>
+
+ * decl.c (last_function_parm_tags): Remove.
+ (current_function_parm_tags): Remove.
+ (init_decl_processing): Adjust.
+ (start_function): Adjust.
+ (store_parm_decls): Adjust.
+
+ PR c++/3152
+ * decl.c (grokdeclarator): Detect when a function typedef is
+ declaring a function, and create last_function_parms correctly.
+
2001-07-25 Jason Merrill <jason_merrill@redhat.com>
* call.c (joust): Only prefer a non-builtin candidate to a builtin
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 4bbf2e0..c9867da 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -243,14 +243,8 @@ tree static_aggregates;
tree integer_two_node, integer_three_node;
-/* Parsing a function declarator leaves here a chain of structure
- and enum types declared in the parmlist. */
-
-static tree last_function_parm_tags;
-
/* Similar, for last_function_parm_tags. */
tree last_function_parms;
-static tree current_function_parm_tags;
/* A list of all LABEL_DECLs in the function that have names. Here so
we can clear out their names' definitions at the end of the
@@ -6565,8 +6559,6 @@ init_decl_processing ()
ggc_add_tree_root (&static_dtors, 1);
ggc_add_tree_root (&lastiddecl, 1);
- ggc_add_tree_root (&last_function_parm_tags, 1);
- ggc_add_tree_root (&current_function_parm_tags, 1);
ggc_add_tree_root (&last_function_parms, 1);
ggc_add_tree_root (&error_mark_list, 1);
@@ -11101,6 +11093,26 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
type = build_cplus_array_type (TREE_TYPE (type), TYPE_DOMAIN (type));
}
+ /* Detect where we're using a typedef of function type to declare a
+ function. last_function_parms will not be set, so we must create
+ it now. */
+
+ if (type == typedef_type && TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ tree decls = NULL_TREE;
+ tree args;
+
+ for (args = TYPE_ARG_TYPES (type); args; args = TREE_CHAIN (args))
+ {
+ tree decl = build_decl (PARM_DECL, NULL_TREE, TREE_VALUE (args));
+
+ TREE_CHAIN (decl) = decls;
+ decls = decl;
+ }
+
+ last_function_parms = nreverse (decls);
+ }
+
/* If this is a type name (such as, in a cast or sizeof),
compute the type and return it now. */
@@ -13296,7 +13308,6 @@ start_function (declspecs, declarator, attrs, flags)
}
last_function_parms = DECL_ARGUMENTS (decl1);
- last_function_parm_tags = NULL_TREE;
}
else
{
@@ -13403,7 +13414,6 @@ start_function (declspecs, declarator, attrs, flags)
/* Save the parm names or decls from this function's declarator
where store_parm_decls will find them. */
current_function_parms = last_function_parms;
- current_function_parm_tags = last_function_parm_tags;
/* Make sure the parameter and return types are reasonable. When
you declare a function, these types can be incomplete, but they
@@ -13630,9 +13640,6 @@ store_parm_decls (current_function_parms)
int parms_have_cleanups = 0;
tree cleanups = NULL_TREE;
- /* This is a list of types declared among parms in a prototype. */
- tree parmtags = current_function_parm_tags;
-
/* This is a chain of any other decls that came in among the parm
declarations. If a parm is declared with enum {foo, bar} x;
then CONST_DECLs for foo and bar are put here. */
@@ -13690,7 +13697,7 @@ store_parm_decls (current_function_parms)
function. This is all and only the PARM_DECLs that were
pushed into scope by the loop above. */
DECL_ARGUMENTS (fndecl) = getdecls ();
- storetags (chainon (parmtags, gettags ()));
+ storetags (gettags ());
}
else
DECL_ARGUMENTS (fndecl) = NULL_TREE;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 805bbb5..c06c779 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2001-07-26 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old-deja/g++.other/crash42.C: New test.
+
2001-07-26 Neil Booth <neil@cat.daikokuya.demon.co.uk>
* gcc.dg/cpp/extratokens.c: Fix.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash42.C b/gcc/testsuite/g++.old-deja/g++.other/crash42.C
new file mode 100644
index 0000000..be316ac
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/crash42.C
@@ -0,0 +1,17 @@
+// Build don't link:
+// Special g++ Options: -g
+//
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 25 Jul 2001 <nathan@codesourcery.com>
+
+// Bug 3152. Using a typedef to declare a function used an unset
+// global variable, last_function_parms.
+
+struct actor
+{
+ typedef bool (operation)();
+
+ operation a;
+ operation b;
+ operation c;
+};