c-parse.in (unary_expr): Move VA_ARG from here ...

* c-parse.in (unary_expr): Move VA_ARG from here ...
        (primary): ... to here.
cp:
        * parse.y (unary_expr): Move VA_ARG from here ...
        (primary): ... to here.

testsuite:
        * g++.old-deja/g++.other/vaarg4.C: New test.
        * gcc.c-torture/compile/20001123-1.c: New test.

From-SVN: r37703
This commit is contained in:
Nathan Sidwell 2000-11-24 10:30:46 +00:00 committed by Nathan Sidwell
parent 3d7e9ba41e
commit 2f401cc807
7 changed files with 46 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2000-11-24 Nathan Sidwell <nathan@codesourcery.com>
* c-parse.in (unary_expr): Move VA_ARG from here ...
(primary): ... to here.
2000-11-23 Graham Stott <grahams@redhat.com>
* expr.c (store_constructor): If a field is non addressable and

View File

@ -514,8 +514,6 @@ unary_expr:
{ $$ = build_unary_op (REALPART_EXPR, $2, 0); }
| IMAGPART cast_expr %prec UNARY
{ $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
| VA_ARG '(' expr_no_commas ',' typename ')'
{ $$ = build_va_arg ($3, groktypename ($5)); }
;
sizeof:
@ -688,6 +686,8 @@ primary:
}
| primary '(' exprlist ')' %prec '.'
{ $$ = build_function_call ($1, $3); }
| VA_ARG '(' expr_no_commas ',' typename ')'
{ $$ = build_va_arg ($3, groktypename ($5)); }
| primary '[' expr ']' %prec '.'
{ $$ = build_array_ref ($1, $3); }
| primary '.' identifier

View File

@ -1,3 +1,8 @@
2000-11-24 Nathan Sidwell <nathan@codesourcery.com>
* parse.y (unary_expr): Move VA_ARG from here ...
(primary): ... to here.
2000-11-24 Nathan Sidwell <nathan@codesourcery.com>
* semantics.c (finish_id_expr): If type is error_mark, return

View File

@ -1252,9 +1252,6 @@ unary_expr:
{ $$ = build_x_unary_op (REALPART_EXPR, $2); }
| IMAGPART cast_expr %prec UNARY
{ $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
| VA_ARG '(' expr_no_commas ',' type_id ')'
{ $$ = build_x_va_arg ($3, groktypename ($5.t));
check_for_new_type ("__builtin_va_arg", $5); }
;
new_placement:
@ -1562,6 +1559,9 @@ primary:
{ $$ = finish_call_expr ($1, $3, 0); }
| primary LEFT_RIGHT
{ $$ = finish_call_expr ($1, NULL_TREE, 0); }
| VA_ARG '(' expr_no_commas ',' type_id ')'
{ $$ = build_x_va_arg ($3, groktypename ($5.t));
check_for_new_type ("__builtin_va_arg", $5); }
| primary '[' expr ']'
{ $$ = grok_array_decl ($$, $3); }
| primary PLUSPLUS

View File

@ -1,3 +1,8 @@
2000-11-24 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.other/vaarg4.C: New test.
* gcc.c-torture/compile/20001123-1.c: New test.
2000-11-24 Nathan Sidwell <nathan@codesourcery.com>
* g++.other/crash24.C: Adjust and remove XFAIL.

View File

@ -0,0 +1,15 @@
// Build don't link:
// Bug 845. We were treating __builtin_va_arg as a unary expr, not a primary,
// and hence getting parse errors.
typedef __builtin_va_list __gnuc_va_list;
typedef __gnuc_va_list va_list;
struct X { int y; };
void func(va_list va)
{
char* a = __builtin_va_arg(va, char**)[0];
int b = __builtin_va_arg(va, X*)->y;
}

View File

@ -0,0 +1,11 @@
typedef __builtin_va_list __gnuc_va_list;
typedef __gnuc_va_list va_list;
struct X { int y; };
void func(va_list va)
{
char* a = __builtin_va_arg(va, char**)[0];
int b = __builtin_va_arg(va, struct X*)->y;
}