a number as a field name

a test program:
    ========
    typedef struct X { int len; } X;
    int main(void) {
       X myX;
       myX.10 = 10;
       return 0;
    }
    ========
    Error message before a patch:
	error: ';' expected (got "(null)")
    After a patch:
	error: field name expected
This commit is contained in:
seyko 2015-09-25 01:44:23 +03:00
parent eb870b006c
commit e7e7a0d301

View File

@ -4152,7 +4152,7 @@ ST_FUNC void unary(void)
if (tok == TOK_INC || tok == TOK_DEC) {
inc(1, tok);
next();
} else if (tok == '.' || tok == TOK_ARROW) {
} else if (tok == '.' || tok == TOK_ARROW || tok == TOK_CDOUBLE) {
int qualifiers;
/* field */
if (tok == TOK_ARROW)
@ -4160,10 +4160,12 @@ ST_FUNC void unary(void)
qualifiers = vtop->type.t & (VT_CONSTANT | VT_VOLATILE);
test_lvalue();
gaddrof();
next();
/* expect pointer on structure */
if ((vtop->type.t & VT_BTYPE) != VT_STRUCT)
expect("struct or union");
if (tok == TOK_CDOUBLE)
expect("field name");
next();
s = vtop->type.ref;
/* find field */
tok |= SYM_FIELD;