OSDN Git Service

PR c/16666
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 30 Oct 2004 08:50:31 +0000 (08:50 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 30 Oct 2004 08:50:31 +0000 (08:50 +0000)
* c-decl.c (start_function): Don't check for DECL_BUILT_IN when
determining whether to copy parameter types from a previous
prototype declaration.

testsuite:
* gcc.dg/dremf-type-compat-1.c, gcc.dg/dremf-type-compat-2.c,
gcc.dg/dremf-type-compat-3.c, gcc.dg/dremf-type-compat-4.c,
gcc.dg/old-style-prom-1.c, gcc.dg/old-style-prom-2.c,
gcc.dg/old-style-prom-3.c: New tests.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89883 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dremf-type-compat-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dremf-type-compat-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dremf-type-compat-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dremf-type-compat-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/old-style-prom-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/old-style-prom-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/old-style-prom-3.c [new file with mode: 0644]

index 2dd6438..e255638 100644 (file)
@@ -1,3 +1,10 @@
+2004-10-30  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/16666
+       * c-decl.c (start_function): Don't check for DECL_BUILT_IN when
+       determining whether to copy parameter types from a previous
+       prototype declaration.
+
 2004-10-29  Roger Sayle  <roger@eyesopen.com>
 
        PR rtl-optimization/17581
index 08f7909..839b5f3 100644 (file)
@@ -5698,11 +5698,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
   DECL_INITIAL (decl1) = error_mark_node;
 
   /* If this definition isn't a prototype and we had a prototype declaration
-     before, copy the arg type info from that prototype.
-     But not if what we had before was a builtin function.  */
+     before, copy the arg type info from that prototype.  */
   old_decl = lookup_name_in_scope (DECL_NAME (decl1), current_scope);
   if (old_decl != 0 && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE
-      && !DECL_BUILT_IN (old_decl)
       && comptypes (TREE_TYPE (TREE_TYPE (decl1)),
                    TREE_TYPE (TREE_TYPE (old_decl)))
       && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0)
index 804e51b..7ccc30d 100644 (file)
@@ -1,3 +1,11 @@
+2004-10-30  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/16666
+       * gcc.dg/dremf-type-compat-1.c, gcc.dg/dremf-type-compat-2.c,
+       gcc.dg/dremf-type-compat-3.c, gcc.dg/dremf-type-compat-4.c,
+       gcc.dg/old-style-prom-1.c, gcc.dg/old-style-prom-2.c,
+       gcc.dg/old-style-prom-3.c: New tests.
+
 2004-10-30  Danny Smith  <dannysmith@users.sourceforge.net>
 
        * gcc.dg/bf-ms-attrib.c: Add protototype for abort.
diff --git a/gcc/testsuite/gcc.dg/dremf-type-compat-1.c b/gcc/testsuite/gcc.dg/dremf-type-compat-1.c
new file mode 100644 (file)
index 0000000..79c55ef
--- /dev/null
@@ -0,0 +1,16 @@
+/* Test for bogus diagnostics for dremf definition.  Although this
+   definition is formally incorrect in ISO C, a GNU extension permits
+   a prototype followed by unpromoted types in a function definition,
+   so it should be permitted when the function is built in.  Bug
+   16666.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+float dremf (float, float);
+
+float
+dremf (x, y)
+     float x, y;
+{
+  return x + y;
+}
diff --git a/gcc/testsuite/gcc.dg/dremf-type-compat-2.c b/gcc/testsuite/gcc.dg/dremf-type-compat-2.c
new file mode 100644 (file)
index 0000000..101da65
--- /dev/null
@@ -0,0 +1,18 @@
+/* Test for bogus diagnostics for dremf definition.  Although this
+   definition is formally incorrect in ISO C, a GNU extension permits
+   a prototype followed by unpromoted types in a function definition,
+   so it should be permitted when the function is built in.  Bug
+   16666.  Test with -pedantic, where the problem should still be
+   diagnosed.  */
+/* { dg-do compile } */
+/* { dg-options "-pedantic" } */
+
+float dremf (float, float); /* { dg-warning "warning: prototype declaration" } */
+
+float
+dremf (x, y)
+     float x;
+     float y;
+{ /* { dg-warning "warning: promoted argument '.' doesn't match prototype" } */
+  return x + y;
+}
diff --git a/gcc/testsuite/gcc.dg/dremf-type-compat-3.c b/gcc/testsuite/gcc.dg/dremf-type-compat-3.c
new file mode 100644 (file)
index 0000000..ff0f509
--- /dev/null
@@ -0,0 +1,18 @@
+/* Test for bogus diagnostics for dremf definition.  Although this
+   definition is formally incorrect in ISO C, a GNU extension permits
+   a prototype followed by unpromoted types in a function definition,
+   so it should be permitted when the function is built in.  Bug
+   16666.  Test with -pedantic-errors, where the problem should still
+   be diagnosed.  */
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+float dremf (float, float); /* { dg-error "error: prototype declaration" } */
+
+float
+dremf (x, y)
+     float x;
+     float y;
+{ /* { dg-error "error: promoted argument '.' doesn't match prototype" } */
+  return x + y;
+}
diff --git a/gcc/testsuite/gcc.dg/dremf-type-compat-4.c b/gcc/testsuite/gcc.dg/dremf-type-compat-4.c
new file mode 100644 (file)
index 0000000..6355fad
--- /dev/null
@@ -0,0 +1,13 @@
+/* Test for bogus diagnostics for dremf definition, as in bug 16666.
+   The GNU extension permitting a prototype to override the promotion
+   of old-style parameter declarations should only apply when the
+   prototype is visible, not for a built-in prototype.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+float
+dremf(x, y)
+     float x, y; /* { dg-warning "warning: conflicting types for built-in function 'dremf'" } */
+{
+  return x + y;
+}
diff --git a/gcc/testsuite/gcc.dg/old-style-prom-1.c b/gcc/testsuite/gcc.dg/old-style-prom-1.c
new file mode 100644 (file)
index 0000000..165ff98
--- /dev/null
@@ -0,0 +1,13 @@
+/* Test for prototype followed by old-style definition, as in
+   dremf-type-compat-1.c but with a non-built-in function.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+float f (float, float);
+
+float
+f (x, y)
+     float x, y;
+{
+  return x + y;
+}
diff --git a/gcc/testsuite/gcc.dg/old-style-prom-2.c b/gcc/testsuite/gcc.dg/old-style-prom-2.c
new file mode 100644 (file)
index 0000000..5f4d877
--- /dev/null
@@ -0,0 +1,14 @@
+/* Test for prototype followed by old-style definition, as in
+   dremf-type-compat-2.c but with a non-built-in function.  */
+/* { dg-do compile } */
+/* { dg-options "-pedantic" } */
+
+float f (float, float); /* { dg-warning "warning: prototype declaration" } */
+
+float
+f (x, y)
+     float x;
+     float y;
+{ /* { dg-warning "warning: promoted argument '.' doesn't match prototype" } */
+  return x + y;
+}
diff --git a/gcc/testsuite/gcc.dg/old-style-prom-3.c b/gcc/testsuite/gcc.dg/old-style-prom-3.c
new file mode 100644 (file)
index 0000000..19bbc8c
--- /dev/null
@@ -0,0 +1,14 @@
+/* Test for prototype followed by old-style definition, as in
+   dremf-type-compat-3.c but with a non-built-in function.  */
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+float f (float, float); /* { dg-error "error: prototype declaration" } */
+
+float
+f (x, y)
+     float x;
+     float y;
+{ /* { dg-error "error: promoted argument '.' doesn't match prototype" } */
+  return x + y;
+}