summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2002-08-15 21:16:52 +0000
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2002-08-15 21:16:52 +0000
commitfbe1cf812f68d1bca64dcbd2e2b548bbfd882f8d (patch)
tree95089cc71f56476e15c245fd3e1233b5298fa642
parent93894129325de7967311711c445aff36dd64bb86 (diff)
downloadppe42-gcc-fbe1cf812f68d1bca64dcbd2e2b548bbfd882f8d.tar.gz
ppe42-gcc-fbe1cf812f68d1bca64dcbd2e2b548bbfd882f8d.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56359 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/decl2.c3
-rw-r--r--gcc/cp/parse.y42
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 <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
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);
OpenPOWER on IntegriCloud