Commit c01b9ec8 by Alexandre Oliva Committed by Alexandre Oliva

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
parent 25587e40
2002-08-15 Alexandre Oliva <aoliva@redhat.com>
* 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 <gdr@nerim.net> 2002-08-15 Gabriel Dos Reis <gdr@nerim.net>
Fix PR/7504 Fix PR/7504
......
...@@ -4717,7 +4717,8 @@ mark_used (decl) ...@@ -4717,7 +4717,8 @@ mark_used (decl)
TREE_USED (decl) = 1; TREE_USED (decl) = 1;
if (processing_template_decl) if (processing_template_decl)
return; return;
assemble_external (decl); if (!skip_evaluation)
assemble_external (decl);
/* Is it a synthesized method that needs to be synthesized? */ /* Is it a synthesized method that needs to be synthesized? */
if (TREE_CODE (decl) == FUNCTION_DECL if (TREE_CODE (decl) == FUNCTION_DECL
......
...@@ -1277,16 +1277,20 @@ unary_expr: ...@@ -1277,16 +1277,20 @@ unary_expr:
/* Refer to the address of a label as a pointer. */ /* Refer to the address of a label as a pointer. */
| ANDAND identifier | ANDAND identifier
{ $$ = finish_label_address_expr ($2); } { $$ = finish_label_address_expr ($2); }
| SIZEOF unary_expr %prec UNARY | sizeof unary_expr %prec UNARY
{ $$ = finish_sizeof ($2); } { $$ = finish_sizeof ($2);
| SIZEOF '(' type_id ')' %prec HYPERUNARY skip_evaluation--; }
| sizeof '(' type_id ')' %prec HYPERUNARY
{ $$ = finish_sizeof (groktypename ($3.t)); { $$ = finish_sizeof (groktypename ($3.t));
check_for_new_type ("sizeof", $3); } check_for_new_type ("sizeof", $3);
| ALIGNOF unary_expr %prec UNARY skip_evaluation--; }
{ $$ = finish_alignof ($2); } | alignof unary_expr %prec UNARY
| ALIGNOF '(' type_id ')' %prec HYPERUNARY { $$ = finish_alignof ($2);
skip_evaluation--; }
| alignof '(' type_id ')' %prec HYPERUNARY
{ $$ = finish_alignof (groktypename ($3.t)); { $$ = 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 /* The %prec EMPTY's here are required by the = init initializer
syntax extension; see below. */ syntax extension; see below. */
...@@ -2004,6 +2008,18 @@ reserved_typespecquals: ...@@ -2004,6 +2008,18 @@ reserved_typespecquals:
{ $$ = tree_cons ($1, NULL_TREE, NULL_TREE); } { $$ = 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). /* A typespec (but not a type qualifier).
Once we have seen one of these in a declaration, Once we have seen one of these in a declaration,
if a typedef name appears then it is being redeclared. */ if a typedef name appears then it is being redeclared. */
...@@ -2015,12 +2031,14 @@ typespec: ...@@ -2015,12 +2031,14 @@ typespec:
{ $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; } { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
| complete_type_name | complete_type_name
{ $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; } { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
| TYPEOF '(' expr ')' | typeof '(' expr ')'
{ $$.t = finish_typeof ($3); { $$.t = finish_typeof ($3);
$$.new_type_flag = 0; $$.lookups = NULL_TREE; } $$.new_type_flag = 0; $$.lookups = NULL_TREE;
| TYPEOF '(' type_id ')' skip_evaluation--; }
| typeof '(' type_id ')'
{ $$.t = groktypename ($3.t); { $$.t = groktypename ($3.t);
$$.new_type_flag = 0; $$.lookups = NULL_TREE; } $$.new_type_flag = 0; $$.lookups = NULL_TREE;
skip_evaluation--; }
| SIGOF '(' expr ')' | SIGOF '(' expr ')'
{ tree type = TREE_TYPE ($3); { tree type = TREE_TYPE ($3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment