This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Fix PR tree-optimization/16876


Bootstrapped/ regtested on i686-pc-linux-gnu.
2006-08-24  J"orn Rennecke  <joern.rennecke@st.com>

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.

Index: c-typeck.c
===================================================================
/usr/bin/diff -p -d -F^( -u -L c-typeck.c	(revision 116347) -L c-typeck.c	(working copy) .svn/text-base/c-typeck.c.svn-base c-typeck.c
--- c-typeck.c	(revision 116347)
+++ c-typeck.c	(working copy)
@@ -4243,7 +4243,7 @@ convert_for_assignment (tree type, tree 
 }
 
 /* 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 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);
Index: testsuite/gcc.dg/noncompile/pr16876.c
===================================================================
/usr/bin/diff -p -d -F^( -u -L testsuite/gcc.dg/noncompile/pr16876.c	(revision 0) -L testsuite/gcc.dg/noncompile/pr16876.c	(revision 0) testsuite/gcc.dg/noncompile/.svn/empty-file testsuite/gcc.dg/noncompile/pr16876.c
--- testsuite/gcc.dg/noncompile/pr16876.c	(revision 0)
+++ testsuite/gcc.dg/noncompile/pr16876.c	(revision 0)
@@ -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);
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]