From 7989f7bd3fd64b7a3da82879a96ba55b708f9a14 Mon Sep 17 00:00:00 2001 From: amylaar Date: Fri, 25 Aug 2006 18:51:57 +0000 Subject: [PATCH] gcc: PR tree-optimization/16876 * c-typeck.c (c_convert_parm_for_inlining): Don't take early exit if PARM doesn't match VALUE. testsuite: gcc.dg/noncompile/pr16876.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116424 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/c-typeck.c | 14 ++++++++++---- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/noncompile/pr16876.c | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/noncompile/pr16876.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c228c3c3626..987e7c29c36 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-08-25 J"orn Rennecke + + PR tree-optimization/16876 + * c-typeck.c (c_convert_parm_for_inlining): Don't take early + exit if PARM doesn't match VALUE. + 2006-08-25 Bob Wilson * config/xtensa/xtensa.h (ASM_OUTPUT_POOL_PROLOGUE): Do not emit a diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c55bcad89c9..42e01d2af52 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4243,7 +4243,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, } /* Convert VALUE for assignment into inlined parameter PARM. ARGNUM - is used for error and waring reporting and indicates which argument + is used for error and warning reporting and indicates which argument is being processed. */ tree @@ -4251,9 +4251,15 @@ c_convert_parm_for_inlining (tree parm, tree value, tree fn, int argnum) { tree ret, type; - /* If FN was prototyped, the value has been converted already - in convert_arguments. */ - if (!value || TYPE_ARG_TYPES (TREE_TYPE (fn))) + /* If FN was prototyped at the call site, the value has been converted + already in convert_arguments. + However, we might see a prototype now that was not in place when + the function call was seen, so check that the VALUE actually matches + PARM before taking an early exit. */ + if (!value + || (TYPE_ARG_TYPES (TREE_TYPE (fn)) + && (TYPE_MAIN_VARIANT (TREE_TYPE (parm)) + == TYPE_MAIN_VARIANT (TREE_TYPE (value))))) return value; type = TREE_TYPE (parm); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2a3192d9a44..8b2850a34e0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2006-08-25 J"orn Rennecke + + gcc.dg/noncompile/pr16876.c: New test. + 2006-08-25 Mark Mitchell PR c++/28056 diff --git a/gcc/testsuite/gcc.dg/noncompile/pr16876.c b/gcc/testsuite/gcc.dg/noncompile/pr16876.c new file mode 100644 index 00000000000..9587849b2fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/pr16876.c @@ -0,0 +1,15 @@ +/* { dg-options "-O -finline-functions" } */ + +static void g(); +struct bigstack { + char space[4096]; +}; + + +void f() { + g(0); /* { dg-error "incompatible type for argument 1 of 'g'" } */ +} + +static void g(struct bigstack bstack) { + g(bstack); +} -- 2.11.4.GIT