summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/enum-compat-1.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-07 22:24:44 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-07 22:24:44 +0000
commit09e0a2a118ffec215309b09e34f77549b3886a79 (patch)
tree758366d4443ad9fd7fd7a5e37a42e69d047dd67a /gcc/testsuite/gcc.dg/enum-compat-1.c
parent06144ff3388710e1c30a18bfdb7d90568624151e (diff)
downloadgcc-09e0a2a118ffec215309b09e34f77549b3886a79.tar.gz
PR c/6024
* c-typeck.c (comptypes): Only treat enumerated types in the same translation unit as compatible with each other when they are the same type. * doc/extend.texi: Update. f: * com.h (ffecom_gfrt_basictype): Correct return type. testsuite: * gcc.dg/enum-compat-1.c: New test. * gcc.c-torture/execute/builtin-types-compatible-p.c: Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75521 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/enum-compat-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/enum-compat-1.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/enum-compat-1.c b/gcc/testsuite/gcc.dg/enum-compat-1.c
new file mode 100644
index 00000000000..04a6e758eff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/enum-compat-1.c
@@ -0,0 +1,32 @@
+/* Test that enumerated types are only considered compatible when they
+ are the same type. PR c/6024. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk>, based on
+ PR c/6024 from Richard Earnshaw <rearnsha@arm.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* Original test from PR c/6024. */
+enum e1 {a, b};
+enum e2 {c, d};
+
+void f(enum e1); /* { dg-error "prototype" "error at decl" } */
+
+void f(x)
+ enum e2 x;
+{ /* { dg-error "doesn't match prototype" "error at defn" } */
+ return;
+}
+
+/* Other compatibility tests. */
+enum e3 { A };
+enum e4 { B };
+
+enum e3 v3;
+enum e4 *p = &v3; /* { dg-warning "incompatible" "incompatible pointer" } */
+enum e3 *q = &v3;
+
+void g(enum e3); /* { dg-error "declaration" "error at first decl" } */
+void g(enum e4); /* { dg-error "conflicting types" "error at second decl" } */
+
+void h(enum e3);
+void h(enum e3);