From c01b9ec8ebca3b360ceb0ca36a685c5bde1f7322 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Thu, 15 Aug 2002 21:16:52 +0000 Subject: [PATCH] parse.y (sizeof, [...]): New non-terminals to increment skip_evaluation. * parse.y (sizeof, alignof, typeof): New non-terminals to increment skip_evaluation. Replace terminals with them and decrement skip_evaluation at the end of rules using them. * decl2.c (mark_used): Don't assemble_external if skipping evaluation. From-SVN: r56359 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/decl2.c | 3 ++- gcc/cp/parse.y | 42 ++++++++++++++++++++++++++++++------------ 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7f3c144ae2a..7d47a099a47 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2002-08-15 Alexandre Oliva + + * parse.y (sizeof, alignof, typeof): New non-terminals to + increment skip_evaluation. Replace terminals with them and + decrement skip_evaluation at the end of rules using them. + * decl2.c (mark_used): Don't assemble_external if + skipping evaluation. + 2002-08-15 Gabriel Dos Reis Fix PR/7504 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 7b10a75c814..960dff3338e 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4717,7 +4717,8 @@ mark_used (decl) TREE_USED (decl) = 1; if (processing_template_decl) return; - assemble_external (decl); + if (!skip_evaluation) + assemble_external (decl); /* Is it a synthesized method that needs to be synthesized? */ if (TREE_CODE (decl) == FUNCTION_DECL diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 02a69d8b4c4..8fe244e6147 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -1277,16 +1277,20 @@ unary_expr: /* Refer to the address of a label as a pointer. */ | ANDAND identifier { $$ = finish_label_address_expr ($2); } - | SIZEOF unary_expr %prec UNARY - { $$ = finish_sizeof ($2); } - | SIZEOF '(' type_id ')' %prec HYPERUNARY + | sizeof unary_expr %prec UNARY + { $$ = finish_sizeof ($2); + skip_evaluation--; } + | sizeof '(' type_id ')' %prec HYPERUNARY { $$ = finish_sizeof (groktypename ($3.t)); - check_for_new_type ("sizeof", $3); } - | ALIGNOF unary_expr %prec UNARY - { $$ = finish_alignof ($2); } - | ALIGNOF '(' type_id ')' %prec HYPERUNARY + check_for_new_type ("sizeof", $3); + skip_evaluation--; } + | alignof unary_expr %prec UNARY + { $$ = finish_alignof ($2); + skip_evaluation--; } + | alignof '(' type_id ')' %prec HYPERUNARY { $$ = finish_alignof (groktypename ($3.t)); - check_for_new_type ("alignof", $3); } + check_for_new_type ("alignof", $3); + skip_evaluation--; } /* The %prec EMPTY's here are required by the = init initializer syntax extension; see below. */ @@ -2004,6 +2008,18 @@ reserved_typespecquals: { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); } ; +sizeof: + SIZEOF { skip_evaluation++; } + ; + +alignof: + ALIGNOF { skip_evaluation++; } + ; + +typeof: + TYPEOF { skip_evaluation++; } + ; + /* A typespec (but not a type qualifier). Once we have seen one of these in a declaration, if a typedef name appears then it is being redeclared. */ @@ -2015,12 +2031,14 @@ typespec: { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; } | complete_type_name { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; } - | TYPEOF '(' expr ')' + | typeof '(' expr ')' { $$.t = finish_typeof ($3); - $$.new_type_flag = 0; $$.lookups = NULL_TREE; } - | TYPEOF '(' type_id ')' + $$.new_type_flag = 0; $$.lookups = NULL_TREE; + skip_evaluation--; } + | typeof '(' type_id ')' { $$.t = groktypename ($3.t); - $$.new_type_flag = 0; $$.lookups = NULL_TREE; } + $$.new_type_flag = 0; $$.lookups = NULL_TREE; + skip_evaluation--; } | SIGOF '(' expr ')' { tree type = TREE_TYPE ($3); -- 2.30.2