https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92215
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Author: mpolacek Date: Fri Nov 8 21:48:47 2019 New Revision: 277991 URL: https://gcc.gnu.org/viewcvs?rev=277991&root=gcc&view=rev Log: PR c++/92215 - flawed diagnostic for bit-field with non-integral type. I noticed that for code like struct S { int *foo : 3; }; we generate nonsensical r.C:2:8: error: function definition does not declare parameters 2 | int *foo : 3; It talks about a function because after parsing the declspecs of 'foo' we don't see either ':' or "name :", so we think it's not a bit-field decl. So we parse the declarator and since a ctor-initializer begins with a ':', we try to parse it as a function body, generating the awful diagnostic. With this patch, we issue: r.C:2:8: error: bit-field ‘foo’ has non-integral type ‘int*’ 2 | int *foo : 3; * parser.c (cp_parser_member_declaration): Add a diagnostic for bit-fields with non-integral types. * g++.dg/diagnostic/bitfld4.C: New test. Added: trunk/gcc/testsuite/g++.dg/diagnostic/bitfld4.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/testsuite/ChangeLog