r277991 - in /trunk/gcc: cp/ChangeLog cp/parser...
mpolacek@gcc.gnu.org
mpolacek@gcc.gnu.org
Fri Nov 8 21:48:00 GMT 2019
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
More information about the Gcc-cvs
mailing list