parse.y (sizeof, [...]): New non-terminals to increment skip_evaluation.
authorAlexandre Oliva <aoliva@redhat.com>
Thu, 15 Aug 2002 21:16:52 +0000 (21:16 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Thu, 15 Aug 2002 21:16:52 +0000 (21:16 +0000)
* 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
gcc/cp/decl2.c
gcc/cp/parse.y

index 7f3c144ae2a5c7d1c4334e5c703d2390840a431b..7d47a099a477bb1a5554dc762168a8af6bd236b7 100644 (file)
@@ -1,3 +1,11 @@
+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>
 
        Fix PR/7504
index 7b10a75c8145496e615e87eb00ecb5b308297e52..960dff3338e794e1a0e6064d6e4680fa19ea2c3f 100644 (file)
@@ -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
index 02a69d8b4c4082e6ffa080a2867b18532e4224c4..8fe244e6147fae3502ea14824047d0e4215e4cb9 100644 (file)
@@ -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);