aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
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/testsuite
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/testsuite')
-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
8 files changed, 114 insertions, 0 deletions
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;
+}