aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2002-08-15 21:16:52 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2002-08-15 21:16:52 +0000
commitc01b9ec8ebca3b360ceb0ca36a685c5bde1f7322 (patch)
tree95089cc71f56476e15c245fd3e1233b5298fa642 /gcc
parent25587e40f5d35cc73b6351b140e4c3d90aed8f7c (diff)
downloadgcc-c01b9ec8ebca3b360ceb0ca36a685c5bde1f7322.zip
gcc-c01b9ec8ebca3b360ceb0ca36a685c5bde1f7322.tar.gz
gcc-c01b9ec8ebca3b360ceb0ca36a685c5bde1f7322.tar.bz2
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
Diffstat (limited to 'gcc')
-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 7f3c144..7d47a09 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 7b10a75..960dff3 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 02a69d8..8fe244e 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);