Paolo's recent commit changed - pedwarn (input_location, OPT_Wpedantic, + pedwarn (declarator->id_loc, OPT_Wpedantic,
but as this testcase shows, declarator might not always be present. So let's brace ourselves for that. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2018-11-28 Marek Polacek <pola...@redhat.com> PR c++/88222 - ICE with bit-field with invalid type. * decl.c (grokdeclarator): Fall back to input_location if declarator is null. * g++.dg/ext/flexary31.C: New test. diff --git gcc/cp/decl.c gcc/cp/decl.c index 1aaf51750ab..8049a71c6f3 100644 --- gcc/cp/decl.c +++ gcc/cp/decl.c @@ -12222,7 +12222,8 @@ grokdeclarator (const cp_declarator *declarator, /* Do not warn on flexible array members in system headers because glibc uses them. */; else if (name) - pedwarn (declarator->id_loc, OPT_Wpedantic, + pedwarn ((declarator ? declarator->id_loc : input_location), + OPT_Wpedantic, "ISO C++ forbids flexible array member %qs", name); else pedwarn (input_location, OPT_Wpedantic, diff --git gcc/testsuite/g++.dg/ext/flexary31.C gcc/testsuite/g++.dg/ext/flexary31.C new file mode 100644 index 00000000000..90f8431a2a4 --- /dev/null +++ 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" } +};