From 3d01dbb2120b4fd6ab5a3354db61e17fb36bc59c Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 24 Nov 2000 10:30:46 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37703 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/c-parse.in | 4 ++-- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parse.y | 6 +++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.old-deja/g++.other/vaarg4.C | 15 +++++++++++++++ gcc/testsuite/gcc.c-torture/compile/20001123-1.c | 11 +++++++++++ 7 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/vaarg4.C create mode 100644 gcc/testsuite/gcc.c-torture/compile/20001123-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index df496a0..650c5dc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2000-11-24 Nathan Sidwell + + * c-parse.in (unary_expr): Move VA_ARG from here ... + (primary): ... to here. + 2000-11-23 Graham Stott * expr.c (store_constructor): If a field is non addressable and diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 5943fa4..d73ba4b 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -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 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b3a5dfd..9bbf5b9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2000-11-24 Nathan Sidwell + * parse.y (unary_expr): Move VA_ARG from here ... + (primary): ... to here. + +2000-11-24 Nathan Sidwell + * semantics.c (finish_id_expr): If type is error_mark, return error_mark. diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index d55f1b9..9e32911 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f4be566..12ded3d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2000-11-24 Nathan Sidwell + * g++.old-deja/g++.other/vaarg4.C: New test. + * gcc.c-torture/compile/20001123-1.c: New test. + +2000-11-24 Nathan Sidwell + * g++.other/crash24.C: Adjust and remove XFAIL. * g++.other/crash37.C: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.other/vaarg4.C b/gcc/testsuite/g++.old-deja/g++.other/vaarg4.C new file mode 100644 index 0000000..3b312ab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vaarg4.C @@ -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; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/20001123-1.c b/gcc/testsuite/gcc.c-torture/compile/20001123-1.c new file mode 100644 index 0000000..5953448 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20001123-1.c @@ -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; +} -- 2.7.4