]> git.pld-linux.org Git - packages/gcc.git/blob - gcc32-typeof-skip-eval.patch
- patches from RH
[packages/gcc.git] / gcc32-typeof-skip-eval.patch
1 2002-08-12  Alexandre Oliva  <aoliva@redhat.com>
2
3         * c-tree.h (skip_evaluation): Move declaration...
4         * c-common.h: ... here.
5         * c-typeck.c (build_external_ref): Don't assemble_external nor
6         mark a tree as used if skip_evaluation is set.
7         * c-parse.in (typeof): New non-terminal to set skip_evaluation
8         around TYPEOF.
9         (typespec_nonreserved_nonattr): Use it.
10
11 --- gcc/cp/parse.y.jj   2002-05-02 12:14:49.000000000 +0200
12 +++ gcc/cp/parse.y      2002-08-22 23:28:34.000000000 +0200
13 @@ -1255,16 +1255,20 @@ unary_expr:
14         /* Refer to the address of a label as a pointer.  */
15         | ANDAND identifier
16                 { $$ = finish_label_address_expr ($2); }
17 -       | SIZEOF unary_expr  %prec UNARY
18 -               { $$ = finish_sizeof ($2); }
19 -       | SIZEOF '(' type_id ')'  %prec HYPERUNARY
20 +       | sizeof unary_expr  %prec UNARY
21 +               { $$ = finish_sizeof ($2);
22 +                 skip_evaluation--; }
23 +       | sizeof '(' type_id ')'  %prec HYPERUNARY
24                 { $$ = finish_sizeof (groktypename ($3.t));
25 -                 check_for_new_type ("sizeof", $3); }
26 -       | ALIGNOF unary_expr  %prec UNARY
27 -               { $$ = finish_alignof ($2); }
28 -       | ALIGNOF '(' type_id ')'  %prec HYPERUNARY
29 -               { $$ = finish_alignof (groktypename ($3.t)); 
30 -                 check_for_new_type ("alignof", $3); }
31 +                 check_for_new_type ("sizeof", $3);
32 +                 skip_evaluation--; }
33 +       | alignof unary_expr  %prec UNARY
34 +               { $$ = finish_alignof ($2);
35 +                 skip_evaluation--; }
36 +       | alignof '(' type_id ')'  %prec HYPERUNARY
37 +               { $$ = finish_alignof (groktypename ($3.t));
38 +                 check_for_new_type ("alignof", $3);
39 +                 skip_evaluation--; }
40  
41         /* The %prec EMPTY's here are required by the = init initializer
42            syntax extension; see below.  */
43 @@ -1989,6 +1993,18 @@ reserved_typespecquals:
44                 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
45         ;
46  
47 +sizeof:
48 +       SIZEOF { skip_evaluation++; }
49 +       ;
50 +
51 +alignof:
52 +       ALIGNOF { skip_evaluation++; }
53 +       ;
54 +
55 +typeof:
56 +       TYPEOF { skip_evaluation++; }
57 +       ;
58 +
59  /* A typespec (but not a type qualifier).
60     Once we have seen one of these in a declaration,
61     if a typedef name appears then it is being redeclared.  */
62 @@ -2000,12 +2016,14 @@ typespec:
63                 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
64         | complete_type_name
65                 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
66 -       | TYPEOF '(' expr ')'
67 +       | typeof '(' expr ')'
68                 { $$.t = finish_typeof ($3);
69 -                 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
70 -       | TYPEOF '(' type_id ')'
71 +                 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
72 +                 skip_evaluation--; }
73 +       | typeof '(' type_id ')'
74                 { $$.t = groktypename ($3.t);
75 -                 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
76 +                 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
77 +                 skip_evaluation--; }
78         | SIGOF '(' expr ')'
79                 { tree type = TREE_TYPE ($3);
80  
81 --- gcc/cp/decl2.c.jj   2002-07-27 01:31:05.000000000 +0200
82 +++ gcc/cp/decl2.c      2002-08-22 23:24:11.000000000 +0200
83 @@ -5179,7 +5179,8 @@ mark_used (decl)
84    TREE_USED (decl) = 1;
85    if (processing_template_decl)
86      return;
87 -  assemble_external (decl);
88 +  if (!skip_evaluation)
89 +    assemble_external (decl);
90  
91    /* Is it a synthesized method that needs to be synthesized?  */
92    if (TREE_CODE (decl) == FUNCTION_DECL
93 --- gcc/c-tree.h.jj     2002-04-02 23:17:23.000000000 +0200
94 +++ gcc/c-tree.h        2002-08-22 23:24:34.000000000 +0200
95 @@ -287,11 +287,6 @@ extern int current_function_returns_null
96  
97  extern int current_function_returns_abnormally;
98  
99 -/* Nonzero means the expression being parsed will never be evaluated.
100 -   This is a count, since unevaluated expressions can nest.  */
101 -
102 -extern int skip_evaluation;
103 -
104  /* Nonzero means `$' can be in an identifier.  */
105  
106  extern int dollars_in_ident;
107 --- gcc/c-common.h.jj   2002-04-17 15:34:36.000000000 +0200
108 +++ gcc/c-common.h      2002-08-22 23:24:11.000000000 +0200
109 @@ -464,6 +464,11 @@ extern int warn_conversion;
110  
111  extern int warn_long_long;
112  
113 +/* Nonzero means the expression being parsed will never be evaluated.
114 +   This is a count, since unevaluated expressions can nest.  */
115 +
116 +extern int skip_evaluation;
117 +
118  /* C types are partitioned into three subsets: object, function, and
119     incomplete types.  */
120  #define C_TYPE_OBJECT_P(type) \
121 --- gcc/c-typeck.c.jj   2002-03-23 12:02:51.000000000 +0100
122 +++ gcc/c-typeck.c      2002-08-22 23:24:11.000000000 +0200
123 @@ -1493,7 +1493,8 @@ build_external_ref (id, fun)
124    if (TREE_TYPE (ref) == error_mark_node)
125      return error_mark_node;
126  
127 -  assemble_external (ref);
128 +  if (!skip_evaluation)
129 +    assemble_external (ref);
130    TREE_USED (ref) = 1;
131  
132    if (TREE_CODE (ref) == CONST_DECL)
133 --- gcc/c-parse.in.jj   2002-04-17 15:34:46.000000000 +0200
134 +++ gcc/c-parse.in      2002-08-22 23:24:11.000000000 +0200
135 @@ -534,6 +534,10 @@ alignof:
136         ALIGNOF { skip_evaluation++; }
137         ;
138  
139 +typeof:
140 +       TYPEOF { skip_evaluation++; }
141 +       ;
142 +
143  cast_expr:
144         unary_expr
145         | '(' typename ')' cast_expr  %prec UNARY
146 @@ -1376,10 +1380,10 @@ ifobjc
147          | non_empty_protocolrefs
148                  { $$ = get_object_reference ($1); }
149  end ifobjc
150 -       | TYPEOF '(' expr ')'
151 -               { $$ = TREE_TYPE ($3); }
152 -       | TYPEOF '(' typename ')'
153 -               { $$ = groktypename ($3); }
154 +       | typeof '(' expr ')'
155 +               { skip_evaluation--; $$ = TREE_TYPE ($3); }
156 +       | typeof '(' typename ')'
157 +               { skip_evaluation--; $$ = groktypename ($3); }
158         ;
159  
160  /* typespec_nonreserved_attr does not exist.  */
This page took 0.047112 seconds and 3 git commands to generate.