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. From-SVN: r277991
Showing
gcc/testsuite/g++.dg/diagnostic/bitfld4.C
0 → 100644
Please
register
or
sign in
to comment