PR c++/88222 - ICE with bit-field with invalid type.
authorMarek Polacek <polacek@redhat.com>
Wed, 28 Nov 2018 20:03:06 +0000 (20:03 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 28 Nov 2018 20:03:06 +0000 (20:03 +0000)
* decl.c (grokdeclarator): Check if declarator is null.

* g++.dg/ext/flexary31.C: New test.

From-SVN: r266581

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/flexary31.C [new file with mode: 0644]

index c0f04d5a0597296fcce2ef1d7933c431983ae6b3..1897c2fa451572e455c6b50ff6b63428a705cbf1 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-28  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/88222 - ICE with bit-field with invalid type.
+       * decl.c (grokdeclarator): Check if declarator is null.
+
 2018-11-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/87476
index 1aaf51750ab1a49cafd209c426cb37fdbdfe4dfb..3734bfe39ace689b2325916b9a4a3a34b8be17f6 100644 (file)
@@ -12221,7 +12221,7 @@ grokdeclarator (const cp_declarator *declarator,
                if (in_system_header_at (input_location))
                  /* Do not warn on flexible array members in system
                     headers because glibc uses them.  */;
-               else if (name)
+               else if (name && declarator)
                  pedwarn (declarator->id_loc, OPT_Wpedantic,
                           "ISO C++ forbids flexible array member %qs", name);
                else
index 86bc7c7119d10e2d6e43030a21b226828d6c510e..fd76bc72070959e7de07f4837b6c5d1b99bbe2c6 100644 (file)
@@ -1,3 +1,8 @@
+2018-11-28  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/88222 - ICE with bit-field with invalid type.
+       * g++.dg/ext/flexary31.C: New test.
+
 2018-11-28  David Edelsohn  <dje.gcc@gmail.com>
 
        * g++.dg/debug/dwarf2/pr86900.C: XFAIL AIX.
diff --git a/gcc/testsuite/g++.dg/ext/flexary31.C b/gcc/testsuite/g++.dg/ext/flexary31.C
new file mode 100644 (file)
index 0000000..90f8431
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/88222
+// { dg-options -Wno-pedantic }
+
+typedef char a[];
+
+class S {
+  a : 4; // { dg-error "bit-field" }
+};