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 for bug 18239


This patch fixes bug 18239, a regression in 4.0 with implicit function
declarations in function prototypes (which can occur in valid C90
code, not just the invalid attributes of the original testcase), i.e. it's 
ice-on-valid-code rather than just ice-on-invalid-code.

Bootstrapped with no regressions on i686-pc-linux-gnu.  Applied to
mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2004-11-01  Joseph S. Myers  <joseph@codesourcery.com>

	PR c/18239
	* c-decl.c (get_parm_info): Allow FUNCTION_DECLs to appear amongst
	parameter declarations.

testsuite:
2004-11-01  Joseph S. Myers  <joseph@codesourcery.com>

	PR c/18239
	* gcc.dg/parm-impl-decl-1.c, gcc.dg/parm-impl-decl-2.c: New tests.

diff -rupN GCC.orig/gcc/c-decl.c GCC/gcc/c-decl.c
--- GCC.orig/gcc/c-decl.c	2004-10-30 08:45:26.000000000 +0000
+++ GCC/gcc/c-decl.c	2004-11-01 14:37:26.000000000 +0000
@@ -4855,10 +4855,13 @@ get_parm_info (bool ellipsis)
 
 	case CONST_DECL:
 	case TYPE_DECL:
+	case FUNCTION_DECL:
 	  /* CONST_DECLs appear here when we have an embedded enum,
 	     and TYPE_DECLs appear here when we have an embedded struct
 	     or union.  No warnings for this - we already warned about the
-	     type itself.  */
+	     type itself.  FUNCTION_DECLs appear when there is an implicit
+	     function declaration in the parameter list.  */
+
 	  TREE_CHAIN (decl) = others;
 	  others = decl;
 	  /* fall through */
@@ -4875,7 +4878,6 @@ get_parm_info (bool ellipsis)
 
 	  /* Other things that might be encountered.  */
 	case LABEL_DECL:
-	case FUNCTION_DECL:
 	case VAR_DECL:
 	default:
 	  gcc_unreachable ();
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/parm-impl-decl-1.c GCC/gcc/testsuite/gcc.dg/parm-impl-decl-1.c
--- GCC.orig/gcc/testsuite/gcc.dg/parm-impl-decl-1.c	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/parm-impl-decl-1.c	2004-11-01 14:44:29.000000000 +0000
@@ -0,0 +1,33 @@
+/* Test implicit function declarations and other odd declarations in
+   function prototypes.  Bug 18239.  */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* Implicit function declaration in attribute in definition (testcase
+   from bug).  */
+int
+foo (int __attribute__ ((__mode__ (vector_size(8)))) i) /* { dg-warning "warning: '__mode__' attribute ignored" } */
+{
+  return (long long) i;
+}
+
+/* Various other cases.  */
+
+int f (int [sizeof(g())]);
+int f1 (int [sizeof(g1())]);
+
+int g () { return 1; }
+
+int
+h (int (*p)[sizeof(i())])
+{
+  int g2 (), g3 ();
+  return (*p)[0] + g3() + g2();
+}
+
+int i () { return 2; }
+
+int f2 (int [sizeof(g2())]);
+int f3 (int [sizeof(g3())]);
+int g3 () { return 4; }
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/parm-impl-decl-2.c GCC/gcc/testsuite/gcc.dg/parm-impl-decl-2.c
--- GCC.orig/gcc/testsuite/gcc.dg/parm-impl-decl-2.c	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/parm-impl-decl-2.c	2004-11-01 14:45:11.000000000 +0000
@@ -0,0 +1,7 @@
+/* Test implicit function declarations and other odd declarations in
+   function prototypes.  Make sure that LABEL_DECLs don't occur.  */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+int k (int [sizeof &&z]); /* { dg-error "error: label 'z' referenced outside of any function" } */


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