re PR c/18498 (gcc allows non-integral bitfield types)
authorJoseph Myers <joseph@codesourcery.com>
Mon, 15 Nov 2004 22:10:16 +0000 (22:10 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Mon, 15 Nov 2004 22:10:16 +0000 (22:10 +0000)
PR c/18498
* c-decl.c (grokdeclarator): Call check_bitfield_type_and_width
after processing the declarator.

testsuite:
* gcc.dg/bitfld-13.c: New test.

From-SVN: r90696

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/bitfld-13.c [new file with mode: 0644]

index ccb32736fecf18f86f8dda2fec40e2ea1f15ee0c..6fe91efe7701181c0d3e913aec93db6e75a15d0d 100644 (file)
@@ -1,3 +1,9 @@
+2004-11-15  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/18498
+       * c-decl.c (grokdeclarator): Call check_bitfield_type_and_width
+       after processing the declarator.
+
 2004-11-15  Aldy Hernandez  <aldyh@redhat.com>
 
        * config/rs6000/altivec.md ("altivec_vsplth"): Rewrite with
index f5bc6e5db6a25dc01665f0a83d8c337727539d8e..709abed0365e20310dc33d20139cdf6d56def42b 100644 (file)
@@ -3809,10 +3809,6 @@ grokdeclarator (const struct c_declarator *declarator,
       && TREE_CODE (type) == INTEGER_TYPE)
     type = c_common_unsigned_type (type);
 
-  /* Check the type and width of a bit-field.  */
-  if (bitfield)
-    check_bitfield_type_and_width (&type, width, orig_name);
-
   /* Figure out the type qualifiers for the declaration.  There are
      two ways a declaration can become qualified.  One is something
      like `const int i' where the `const' is explicit.  Another is
@@ -4252,6 +4248,10 @@ grokdeclarator (const struct c_declarator *declarator,
 
   /* Now TYPE has the actual type.  */
 
+  /* Check the type and width of a bit-field.  */
+  if (bitfield)
+    check_bitfield_type_and_width (&type, width, orig_name);
+
   /* Did array size calculations overflow?  */
 
   if (TREE_CODE (type) == ARRAY_TYPE
index c24cf1ba09beb5d3d9d8b489376f142fc829fbef..4ea1f12bac57ddc4923ff074f159caa9c696c3ca 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-15  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/18498
+       * gcc.dg/bitfld-13.c: New test.
+
 2004-11-15  Janis Johnson  <janis187@us.ibm.com>
 
        * gcc.dg/vect/tree-vect.h: (check_vect): Test symbols defined for
diff --git a/gcc/testsuite/gcc.dg/bitfld-13.c b/gcc/testsuite/gcc.dg/bitfld-13.c
new file mode 100644 (file)
index 0000000..012a3e5
--- /dev/null
@@ -0,0 +1,14 @@
+/* Test invalid bit-field types: bug 18498.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+int
+main(void)
+{
+  struct X {
+    int s[20] : 1; /* { dg-error "error: bit-field 's' has invalid type" } */
+    int *p : 2; /* { dg-error "error: bit-field 'p' has invalid type" } */
+    int (*f)(float) : 3; /* { dg-error "error: bit-field 'f' has invalid type" } */
+  } x;
+  return 0;
+}