]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
parse.y (sizeof, [...]): New non-terminals to increment skip_evaluation.
authorAlexandre Oliva <aoliva@redhat.com>
Sun, 1 Sep 2002 20:10:32 +0000 (20:10 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Sun, 1 Sep 2002 20:10:32 +0000 (20:10 +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: r56726

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/parse.y

index 8fcb4aad158192be8280cc9948c14f16e74f6f20..f21cf2a8d15ad6702f3138b037a019e7b1eb22ee 100644 (file)
@@ -1,3 +1,11 @@
+2002-09-01  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-31  Jason Merrill  <jason@redhat.com>
 
        * cp-lang.c (cp_expr_size): Don't abort.
index 09a30f4a007f51ed57749170777db5bbbde072b3..0eb47994b20ab07afefe1283ebf588e7fb569377 100644 (file)
@@ -5186,7 +5186,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 d1e3761febf7f6948c1cb96d9d8365fbac306d22..678262198a94c99fc9c4f5be0533c84053935a9f 100644 (file)
@@ -1255,16 +1255,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.  */
@@ -1989,6 +1993,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.  */
@@ -2000,12 +2016,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);