From bdd0bd5c96a1f3a51bcfe0cc5b0ffd3ff6f0280e Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 28 Nov 2018 20:03:06 +0000 Subject: [PATCH] PR c++/88222 - ICE with bit-field with invalid type. * decl.c (grokdeclarator): Check if declarator is null. * g++.dg/ext/flexary31.C: New test. From-SVN: r266581 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/flexary31.C | 8 ++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/flexary31.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c0f04d5a059..1897c2fa451 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-11-28 Marek Polacek + + PR c++/88222 - ICE with bit-field with invalid type. + * decl.c (grokdeclarator): Check if declarator is null. + 2018-11-28 Jakub Jelinek PR c++/87476 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1aaf51750ab..3734bfe39ac 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 86bc7c7119d..fd76bc72070 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-11-28 Marek Polacek + + PR c++/88222 - ICE with bit-field with invalid type. + * g++.dg/ext/flexary31.C: New test. + 2018-11-28 David Edelsohn * 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 index 00000000000..90f8431a2a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/flexary31.C @@ -0,0 +1,8 @@ +// PR c++/88222 +// { dg-options -Wno-pedantic } + +typedef char a[]; + +class S { + a : 4; // { dg-error "bit-field" } +}; -- 2.30.2