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]

[PATCH] Fix PR c/35750: ICE with invalid old-style parameter declaration


The following patch fixes an ICE with invalid parameters in old-style
function definitions. If there's already a new-style declaration
available store_parm_decls_oldstyle iterates over all arguments to
adjust them to match the new-style prototype.
However, this crashes if an argument with invalid type is encountered.
Fixed by skipping these invalid arguments.

Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for mainline?

Regards,
Volker

:ADDPATCH C:


2008-03-30  Volker Reichelt  <v.reichelt@netcologne.de>

	PR c/35750
	* c-decl.c (store_parm_decls_oldstyle): Skip invalid parameters.

===================================================================
--- gcc/c-decl.c	2008-03-01 12:02:22 +0100
+++ gcc/c-decl.c	2008-03-30 15:09:42 +0200
@@ -6483,8 +6483,10 @@ store_parm_decls_oldstyle (tree fndecl, 
 	  /* Type for passing arg must be consistent with that
 	     declared for the arg.  ISO C says we take the unqualified
 	     type for parameters declared with qualified type.  */
-	  if (!comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)),
-			  TYPE_MAIN_VARIANT (TREE_VALUE (type))))
+	  if (TREE_TYPE (parm) != error_mark_node
+	      && TREE_TYPE (type) != error_mark_node
+	      && !comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)),
+			     TYPE_MAIN_VARIANT (TREE_VALUE (type))))
 	    {
 	      if (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
 		  == TYPE_MAIN_VARIANT (TREE_VALUE (type)))
===================================================================

2008-03-30  Volker Reichelt  <v.reichelt@netcologne.de>

	PR c/35750
	* gcc.dg/old-style-param-1.c: New test.

===================================================================
--- gcc/testsuite/gcc.dg/old-style-param-1.c	2003-09-23 19:59:22 +0200
+++ gcc/testsuite/gcc.dg/old-style-param-1.c	2008-03-30 15:21:49 +0200
@@ -0,0 +1,4 @@
+/* PR c/35750 */
+
+void foo(int[]);
+void foo(x) int x[](); {} /* { dg-error "array of functions" } */
===================================================================


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