diff options
author | Jan Hubicka <jh@suse.cz> | 2008-01-30 16:54:14 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2008-01-30 15:54:14 +0000 |
commit | d6951cae074778035bfd782bd863883aeb79460b (patch) | |
tree | fb782223c88f1e362d6ccb5a3c73df5e74e578a8 | |
parent | 7f92e24236b7a7cc238fa65b6843de0cfa92778c (diff) | |
download | gcc-d6951cae074778035bfd782bd863883aeb79460b.zip gcc-d6951cae074778035bfd782bd863883aeb79460b.tar.gz gcc-d6951cae074778035bfd782bd863883aeb79460b.tar.bz2 |
re PR target/34982 (calling a function with undefined parameters causes segmentation fault at -O1 or higher)
PR target/34982
* i386.c (init_cumulative_args): Use real function declaration when
calling locally.
From-SVN: r131966
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr34982.c | 14 |
4 files changed, 35 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f2021d2..58735a1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-01-30 Jan Hubicka <jh@suse.cz> + + PR target/34982 + * i386.c (init_cumulative_args): Use real function declaration when + calling locally. + 2008-01-30 Richard Sandiford <rsandifo@nildram.co.uk> PR rtl-optimization/34998 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 6e9ae2a..4e5cb22 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -3432,6 +3432,7 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, /* Argument info to initialize */ rtx libname, /* SYMBOL_REF of library name or 0 */ tree fndecl) { + struct cgraph_local_info *i = fndecl ? cgraph_local_info (fndecl) : NULL; memset (cum, 0, sizeof (*cum)); /* Set up the number of registers to use for passing arguments. */ @@ -3442,6 +3443,15 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, /* Argument info to initialize */ cum->mmx_nregs = MMX_REGPARM_MAX; cum->warn_sse = true; cum->warn_mmx = true; + + /* Because type might mismatch in between caller and callee, we need to + use actual type of function for local calls. + FIXME: cgraph_analyze can be told to actually record if function uses + va_start so for local functions maybe_vaarg can be made aggressive + helping K&R code. + FIXME: once typesytem is fixed, we won't need this code anymore. */ + if (i && i->local) + fntype = TREE_TYPE (fndecl); cum->maybe_vaarg = (fntype ? (!prototype_p (fntype) || stdarg_p (fntype)) : !libname); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3cee20a..24c8923 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-01-30 Jan Hubicka <jh@suse.cz> + + PR target/34982 + * gcc.c-torture/execute/pr34982.c: New testcase + 2008-01-30 Andreas Krebbel <krebbel1@de.ibm.com> * gcc.target/s390/tf_to_di-1.c: New testcase. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr34982.c b/gcc/testsuite/gcc.c-torture/execute/pr34982.c new file mode 100644 index 0000000..f7ad67c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr34982.c @@ -0,0 +1,14 @@ +extern void abort (void); + +static void something(); + +int main() +{ + something(-1); +} + +static void something(int i) +{ + if (i != -1) + abort (); +} |