* gcc.dg/cast-qual-2.c: New test.
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Feb 2002 17:02:39 +0000 (17:02 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Feb 2002 17:02:39 +0000 (17:02 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49482 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cast-qual-2.c [new file with mode: 0644]

index fe11a62..3aeb21c 100644 (file)
@@ -1,3 +1,7 @@
+2002-02-04  Richard Sandiford  <rsandifo@redhat.com>
+
+       * gcc.dg/cast-qual-2.c: New test.
+
 2002-02-04  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/20020201-4.c: New test.
diff --git a/gcc/testsuite/gcc.dg/cast-qual-2.c b/gcc/testsuite/gcc.dg/cast-qual-2.c
new file mode 100644 (file)
index 0000000..0be1d61
--- /dev/null
@@ -0,0 +1,34 @@
+/* Test whether the -Wcast-qual handles cv-qualified functions correctly.  */
+/* { dg-do compile } */
+/* { dg-options "-Wcast-qual" } */
+
+typedef int (intfn_t) (int);
+typedef void (voidfn_t) (void);
+
+typedef const intfn_t *constfn_t;
+typedef volatile voidfn_t *noreturnfn_t;
+
+intfn_t intfn;
+const intfn_t constfn;
+voidfn_t voidfn;
+volatile voidfn_t noreturnfn;
+
+intfn_t *i1 = intfn;
+intfn_t *i2 = (intfn_t *) intfn;
+intfn_t *i3 = constfn;
+intfn_t *i4 = (intfn_t *) constfn; /* { dg-bogus "discards qualifier" } */
+
+constfn_t p1 = intfn; /* { dg-warning "makes qualified function" } */
+constfn_t p2 = (constfn_t) intfn; /* { dg-warning "new qualifier" } */
+constfn_t p3 = constfn;
+constfn_t p4 = (constfn_t) constfn;
+
+voidfn_t *v1 = voidfn;
+voidfn_t *v2 = (voidfn_t *) voidfn;
+voidfn_t *v3 = noreturnfn;
+voidfn_t *v4 = (voidfn_t *) noreturnfn; /* { dg-bogus "discards qualifier" } */
+
+noreturnfn_t n1 = voidfn; /* { dg-warning "makes qualified function" } */
+noreturnfn_t n2 = (noreturnfn_t) voidfn; /* { dg-warning "new qualifier" } */
+noreturnfn_t n3 = noreturnfn;
+noreturnfn_t n4 = (noreturnfn_t) noreturnfn;