aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2004-10-30 09:50:31 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2004-10-30 09:50:31 +0100
commit46097c763954059fdbd8fa5859c3a6a744096d8b (patch)
treef14d7c8e29c272504247e1d4eb33a70e85877d14 /gcc
parent514a3b1100835a73bc91d2bfcc897929a792e85b (diff)
downloadgcc-46097c763954059fdbd8fa5859c3a6a744096d8b.zip
gcc-46097c763954059fdbd8fa5859c3a6a744096d8b.tar.gz
gcc-46097c763954059fdbd8fa5859c3a6a744096d8b.tar.bz2
re PR c/16666 (dremf type conflict)
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. 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. From-SVN: r89883
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/c-decl.c4
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/dremf-type-compat-1.c16
-rw-r--r--gcc/testsuite/gcc.dg/dremf-type-compat-2.c18
-rw-r--r--gcc/testsuite/gcc.dg/dremf-type-compat-3.c18
-rw-r--r--gcc/testsuite/gcc.dg/dremf-type-compat-4.c13
-rw-r--r--gcc/testsuite/gcc.dg/old-style-prom-1.c13
-rw-r--r--gcc/testsuite/gcc.dg/old-style-prom-2.c14
-rw-r--r--gcc/testsuite/gcc.dg/old-style-prom-3.c14
10 files changed, 122 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2dd6438..e255638 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 08f7909..839b5f3 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 804e51b..7ccc30d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..79c55ef
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dremf-type-compat-1.c
@@ -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
index 0000000..101da65
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dremf-type-compat-2.c
@@ -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
index 0000000..ff0f509
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dremf-type-compat-3.c
@@ -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
index 0000000..6355fad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dremf-type-compat-4.c
@@ -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
index 0000000..165ff98
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/old-style-prom-1.c
@@ -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
index 0000000..5f4d877
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/old-style-prom-2.c
@@ -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
index 0000000..19bbc8c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/old-style-prom-3.c
@@ -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;
+}