Subversion Repositories tendra.SVN

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2006 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 57... Line 87...
57
    CONVERT BY ASSIGNMENT
87
    CONVERT BY ASSIGNMENT
58
 
88
 
59
    This routine converts the expression a to the type t, as if by
89
    This routine converts the expression a to the type t, as if by
60
    assignment.  The cases where t is a class type or a reference are
90
    assignment.  The cases where t is a class type or a reference are
61
    handled elsewhere.
91
    handled elsewhere.
62
*/
92
*/
63
 
93
 
64
EXP convert_assign
94
EXP
65
    PROTO_N ( ( t, a, err ) )
-
 
66
    PROTO_T ( TYPE t X EXP a X ERROR *err )
95
convert_assign(TYPE t, EXP a, ERROR *err)
67
{
96
{
68
    EXP e = cast_exp ( t, a, err, CAST_IMPLICIT ) ;
97
	EXP e = cast_exp(t, a, err, CAST_IMPLICIT);
69
    return ( e ) ;
98
	return (e);
70
}
99
}
71
 
100
 
72
 
101
 
73
/*
102
/*
74
    CONVERT TO A CLASS TYPE BY ASSIGNMENT
103
    CONVERT TO A CLASS TYPE BY ASSIGNMENT
75
 
104
 
76
    This routine converts the expression a to the class t, as if by
105
    This routine converts the expression a to the class t, as if by
77
    assignment.  The constructors of t are ignored, only base class
106
    assignment.  The constructors of t are ignored, only base class
78
    conversions and conversion operators being considered.
107
    conversions and conversion operators being considered.
79
*/
108
*/
80
 
109
 
81
EXP convert_class
110
EXP
82
    PROTO_N ( ( t, a, err ) )
-
 
83
    PROTO_T ( TYPE t X EXP a X ERROR *err )
111
convert_class(TYPE t, EXP a, ERROR *err)
84
{
112
{
85
    EXP e ;
113
	EXP e;
86
    TYPE s = DEREF_type ( exp_type ( a ) ) ;
114
	TYPE s = DEREF_type(exp_type(a));
87
    if ( IS_type_compound ( s ) ) {
115
	if (IS_type_compound(s)) {
88
	e = cast_class_class ( t, a, err, CAST_IMPLICIT, 0 ) ;
116
		e = cast_class_class(t, a, err, CAST_IMPLICIT, 0);
89
	if ( !IS_NULL_exp ( e ) ) return ( e ) ;
117
		if (!IS_NULL_exp(e)) {
-
 
118
			return (e);
90
    }
119
		}
-
 
120
	}
91
    e = convert_conv ( t, a, err, CAST_IMPLICIT ) ;
121
	e = convert_conv(t, a, err, CAST_IMPLICIT);
92
    return ( e ) ;
122
	return (e);
93
}
123
}
94
 
124
 
95
 
125
 
96
/*
126
/*
97
    CONSTRUCT A POSTFIX EXPRESSION
127
    CONSTRUCT A POSTFIX EXPRESSION
98
 
128
 
99
    This routine constructs the expressions 'a++' and 'a--'.  Note that
129
    This routine constructs the expressions 'a++' and 'a--'.  Note that
100
    in this and other assignment expressions, a cannot have array type,
130
    in this and other assignment expressions, a cannot have array type,
101
    so that no bounds checks are appropriate.  The result is an rvalue.
131
    so that no bounds checks are appropriate.  The result is an rvalue.
102
*/
132
*/
103
 
133
 
104
EXP make_postfix_exp
134
EXP
105
    PROTO_N ( ( op, a ) )
-
 
106
    PROTO_T ( int op X EXP a )
135
make_postfix_exp(int op, EXP a)
107
{
136
{
108
    EXP e ;
137
	EXP e;
109
    TYPE ta ;
138
	TYPE ta;
110
    ERROR err ;
139
	ERROR err;
111
    unsigned ca ;
140
	unsigned ca;
112
 
141
 
113
    /* An assignment is a side effect */
142
	/* An assignment is a side effect */
114
    no_side_effects++ ;
143
	no_side_effects++;
115
 
144
 
116
    /* Allow for reference conversions */
145
	/* Allow for reference conversions */
117
    a = convert_reference ( a, REF_NORMAL ) ;
146
	a = convert_reference(a, REF_NORMAL);
118
    ta = DEREF_type ( exp_type ( a ) ) ;
147
	ta = DEREF_type(exp_type(a));
119
    ca = type_category ( &ta ) ;
148
	ca = type_category(&ta);
120
 
149
 
121
    /* Check for overloading */
150
	/* Check for overloading */
122
#if LANGUAGE_CPP
151
#if LANGUAGE_CPP
123
    if ( IS_TYPE_OVERLOAD ( ca ) ) {
152
	if (IS_TYPE_OVERLOAD(ca)) {
124
	if ( overload_depth == 0 ) {
153
		if (overload_depth == 0) {
125
	    /* Overloads as 'operator op ( a, 0 )' */
154
			/* Overloads as 'operator op ( a, 0 )' */
126
	    EXP b = make_null_exp ( type_sint ) ;
155
			EXP b = make_null_exp(type_sint);
127
	    e = binary_overload ( op, a, b ) ;
156
			e = binary_overload(op, a, b);
128
	    return ( e ) ;
157
			return (e);
-
 
158
		}
-
 
159
		if (IS_TYPE_CLASS(ca)) {
-
 
160
			goto error_lab;
-
 
161
		}
129
	}
162
	}
130
	if ( IS_TYPE_CLASS ( ca ) ) goto error_lab ;
-
 
131
    }
-
 
132
#else
163
#else
133
    if ( IS_TYPE_CLASS ( ca ) ) goto error_lab ;
164
	if (IS_TYPE_CLASS(ca)) {
-
 
165
		goto error_lab;
-
 
166
	}
134
#endif
167
#endif
135
 
168
 
136
    /* Operand should be a modifiable lvalue */
169
	/* Operand should be a modifiable lvalue */
137
    err = check_modifiable ( ta, a ) ;
170
	err = check_modifiable(ta, a);
138
    if ( !IS_NULL_err ( err ) ) {
171
	if (!IS_NULL_err(err)) {
139
	err = concat_error ( err, ERR_expr_post_incr_mod ( op ) ) ;
172
		err = concat_error(err, ERR_expr_post_incr_mod(op));
140
	report ( crt_loc, err ) ;
173
		report(crt_loc, err);
141
	err = NULL_err ;
174
		err = NULL_err;
142
    }
175
	}
143
 
176
 
144
    /* Operand can be arithmetic ... */
177
	/* Operand can be arithmetic ... */
145
    if ( IS_TYPE_ARITH ( ca ) ) {
178
	if (IS_TYPE_ARITH(ca)) {
146
	EXP b ;
179
		EXP b;
147
	TYPE t ;
180
		TYPE t;
148
	TYPE tb ;
181
		TYPE tb;
149
	OFFSET off = NULL_off ;
182
		OFFSET off = NULL_off;
-
 
183
 
-
 
184
		/* Allow for bitfields */
-
 
185
		if (IS_TYPE_BITF(ca)) {
-
 
186
			off = decons_bitf_exp(&a);
-
 
187
		}
-
 
188
 
-
 
189
		/* Form the result */
-
 
190
		MAKE_exp_dummy(ta, a, LINK_NONE, off, 0, a);
-
 
191
		b = convert_lvalue(a);
-
 
192
		tb = DEREF_type(exp_type(b));
-
 
193
		t = promote_type(tb);
-
 
194
		if (IS_NULL_off(off)) {
-
 
195
			MAKE_exp_dummy(tb, b, LINK_NONE, NULL_off, 0, b);
-
 
196
			e = convert_promote(t, b);
-
 
197
		} else {
-
 
198
			b = convert_promote(t, b);
-
 
199
			MAKE_exp_dummy(t, b, LINK_NONE, NULL_off, 0, b);
-
 
200
			e = b;
-
 
201
			tb = t;
-
 
202
		}
-
 
203
		if (check_int_type(ta, btype_bool)) {
-
 
204
			/* Booleans are weird */
-
 
205
			unsigned v = BOOL_TRUE;
-
 
206
			if (op == lex_plus_Hplus) {
-
 
207
				report(crt_loc,
-
 
208
				       ERR_expr_post_incr_bool_inc(op, ta));
-
 
209
			} else {
-
 
210
				report(crt_loc,
-
 
211
				       ERR_expr_post_incr_bool_dec(op, ta));
-
 
212
				v = BOOL_FALSE;
-
 
213
			}
-
 
214
			e = make_bool_exp(v, exp_int_lit_tag);
-
 
215
		} else {
-
 
216
			/* Other types are simple */
-
 
217
			EXP c = make_unit_exp(t);
-
 
218
			if (op == lex_plus_Hplus) {
-
 
219
				MAKE_exp_plus(t, e, c, e);
-
 
220
			} else {
-
 
221
				MAKE_exp_minus(t, e, c, e);
-
 
222
			}
-
 
223
			e = convert_assign(ta, e, &err);
-
 
224
			if (!IS_NULL_err(err)) {
-
 
225
				err = concat_warning(err, ERR_expr_ass_conv());
-
 
226
				report(crt_loc, err);
-
 
227
			}
-
 
228
		}
-
 
229
		MAKE_exp_postinc(tb, a, b, e, e);
-
 
230
		return (e);
-
 
231
	}
-
 
232
 
-
 
233
	/* ... or pointer ... */
-
 
234
	if (IS_TYPE_PTR(ca)) {
-
 
235
		/* Pointer must be to complete object type */
-
 
236
		EXP b;
-
 
237
		OFFSET off;
-
 
238
		TYPE t = check_pointer(ta, &err);
-
 
239
		if (!IS_NULL_err(err)) {
-
 
240
			err = concat_error(err, ERR_expr_post_incr_incompl(op));
-
 
241
			report(crt_loc, err);
-
 
242
		}
-
 
243
		if (IS_type_top_etc(t)) {
-
 
244
			t = type_char;
-
 
245
		}
-
 
246
 
-
 
247
		/* Create the identities */
-
 
248
		MAKE_exp_dummy(ta, a, LINK_NONE, NULL_off, 0, a);
-
 
249
		b = convert_lvalue(a);
-
 
250
		ta = DEREF_type(exp_type(b));
-
 
251
		MAKE_exp_dummy(ta, b, LINK_NONE, NULL_off, 0, b);
150
 
252
 
151
	/* Allow for bitfields */
-
 
152
	if ( IS_TYPE_BITF ( ca ) ) off = decons_bitf_exp ( &a ) ;
-
 
153
 
-
 
154
	/* Form the result */
253
		/* Form the result */
155
	MAKE_exp_dummy ( ta, a, LINK_NONE, off, 0, a ) ;
-
 
156
	b = convert_lvalue ( a ) ;
-
 
157
	tb = DEREF_type ( exp_type ( b ) ) ;
-
 
158
	t = promote_type ( tb ) ;
254
		MAKE_off_type(t, off);
159
	if ( IS_NULL_off ( off ) ) {
255
		if (op == lex_minus_Hminus) {
160
	    MAKE_exp_dummy ( tb, b, LINK_NONE, NULL_off, 0, b ) ;
-
 
161
	    e = convert_promote ( t, b ) ;
256
			MAKE_off_negate(off, off);
162
	} else {
257
		}
163
	    b = convert_promote ( t, b ) ;
258
		e = make_add_ptr(ta, b, off);
164
	    MAKE_exp_dummy ( t, b, LINK_NONE, NULL_off, 0, b ) ;
259
		MAKE_exp_postinc(ta, a, b, e, e);
165
	    e = b ;
-
 
166
	    tb = t ;
260
		return (e);
167
	}
261
	}
168
	if ( check_int_type ( ta, btype_bool ) ) {
-
 
169
	    /* Booleans are weird */
-
 
170
	    unsigned v = BOOL_TRUE ;
-
 
171
	    if ( op == lex_plus_Hplus ) {
-
 
172
		report ( crt_loc, ERR_expr_post_incr_bool_inc ( op, ta ) ) ;
-
 
173
	    } else {
-
 
174
		report ( crt_loc, ERR_expr_post_incr_bool_dec ( op, ta ) ) ;
-
 
175
		v = BOOL_FALSE ;
-
 
176
	    }
-
 
177
	    e = make_bool_exp ( v, exp_int_lit_tag ) ;
-
 
178
	} else {
-
 
179
	    /* Other types are simple */
-
 
180
	    EXP c = make_unit_exp ( t ) ;
-
 
181
	    if ( op == lex_plus_Hplus ) {
-
 
182
		MAKE_exp_plus ( t, e, c, e ) ;
-
 
183
	    } else {
-
 
184
		MAKE_exp_minus ( t, e, c, e ) ;
-
 
185
	    }
-
 
186
	    e = convert_assign ( ta, e, &err ) ;
-
 
187
	    if ( !IS_NULL_err ( err ) ) {
-
 
188
		err = concat_warning ( err, ERR_expr_ass_conv () ) ;
-
 
189
		report ( crt_loc, err ) ;
-
 
190
	    }
-
 
191
	}
-
 
192
	MAKE_exp_postinc ( tb, a, b, e, e ) ;
-
 
193
	return ( e ) ;
-
 
194
    }
-
 
195
 
-
 
196
    /* ... or pointer ... */
-
 
197
    if ( IS_TYPE_PTR ( ca ) ) {
-
 
198
	/* Pointer must be to complete object type */
-
 
199
	EXP b ;
-
 
200
	OFFSET off ;
-
 
201
	TYPE t = check_pointer ( ta, &err ) ;
-
 
202
	if ( !IS_NULL_err ( err ) ) {
-
 
203
	    err = concat_error ( err, ERR_expr_post_incr_incompl ( op ) ) ;
-
 
204
	    report ( crt_loc, err ) ;
-
 
205
	}
-
 
206
	if ( IS_type_top_etc ( t ) ) t = type_char ;
-
 
207
 
-
 
208
	/* Create the identities */
-
 
209
	MAKE_exp_dummy ( ta, a, LINK_NONE, NULL_off, 0, a ) ;
-
 
210
	b = convert_lvalue ( a ) ;
-
 
211
	ta = DEREF_type ( exp_type ( b ) ) ;
-
 
212
	MAKE_exp_dummy ( ta, b, LINK_NONE, NULL_off, 0, b ) ;
-
 
213
 
-
 
214
	/* Form the result */
-
 
215
	MAKE_off_type ( t, off ) ;
-
 
216
	if ( op == lex_minus_Hminus ) MAKE_off_negate ( off, off ) ;
-
 
217
	e = make_add_ptr ( ta, b, off ) ;
-
 
218
	MAKE_exp_postinc ( ta, a, b, e, e ) ;
-
 
219
	return ( e ) ;
-
 
220
    }
-
 
221
 
262
 
222
    /* ... and nothing else */
263
	/* ... and nothing else */
223
    error_lab : {
264
error_lab:
224
	if ( !IS_TYPE_ERROR ( ca ) ) {
265
	if (!IS_TYPE_ERROR(ca)) {
225
	    report ( crt_loc, ERR_expr_post_incr_op ( op, ta ) ) ;
266
		report(crt_loc, ERR_expr_post_incr_op(op, ta));
226
	}
267
	}
227
    }
-
 
228
    e = make_error_exp ( 0 ) ;
268
	e = make_error_exp(0);
229
    return ( e ) ;
269
	return (e);
230
}
270
}
231
 
271
 
232
 
272
 
233
/*
273
/*
234
    CREATE A PRE-INCREMENT EXPRESSION
274
    CREATE A PRE-INCREMENT EXPRESSION
Line 240... Line 280...
240
    latter case when t is a bitfield: the value is not b, but
280
    latter case when t is a bitfield: the value is not b, but
241
    convert_bitfield ( b ).  This conversion is left implicit, and is
281
    convert_bitfield ( b ).  This conversion is left implicit, and is
242
    only made explicit in the TDF output routines.
282
    only made explicit in the TDF output routines.
243
*/
283
*/
244
 
284
 
245
static EXP make_preinc_exp
285
static EXP
246
    PROTO_N ( ( t, a, b, off, op ) )
-
 
247
    PROTO_T ( TYPE t X EXP a X EXP b X OFFSET off X int op )
286
make_preinc_exp(TYPE t, EXP a, EXP b, OFFSET off, int op)
248
{
287
{
249
    EXP e ;
288
	EXP e;
250
#if LANGUAGE_C
289
#if LANGUAGE_C
251
    t = rvalue_type ( t ) ;
290
	t = rvalue_type(t);
252
#endif
291
#endif
253
    if ( IS_NULL_off ( off ) ) {
292
	if (IS_NULL_off(off)) {
254
	/* Simple case */
293
		/* Simple case */
255
	if ( op == lex_assign ) {
294
		if (op == lex_assign) {
256
	    MAKE_exp_assign ( t, a, b, e ) ;
295
			MAKE_exp_assign(t, a, b, e);
-
 
296
		} else {
-
 
297
			MAKE_exp_preinc(t, a, b, op, e);
-
 
298
		}
257
	} else {
299
	} else {
-
 
300
		/* Bitfield case */
-
 
301
#if LANGUAGE_C
258
	    MAKE_exp_preinc ( t, a, b, op, e ) ;
302
		MAKE_exp_preinc(t, a, b, op, e);
-
 
303
		t = promote_type(t);
-
 
304
#else
-
 
305
		TYPE p;
-
 
306
		TYPE s = find_bitfield_type(t);
-
 
307
		MAKE_type_ptr(cv_none, s, p);
-
 
308
		s = lvalue_type(s);
-
 
309
		MAKE_exp_preinc(s, a, b, op, e);
-
 
310
		MAKE_exp_address(p, e, e);
-
 
311
		MAKE_exp_add_ptr(p, e, off, 0, e);
-
 
312
		MAKE_exp_indir(t, e, e);
-
 
313
#endif
259
	}
314
	}
260
    } else {
-
 
261
	/* Bitfield case */
-
 
262
#if LANGUAGE_C
315
#if LANGUAGE_C
263
	MAKE_exp_preinc ( t, a, b, op, e ) ;
-
 
264
	t = promote_type ( t ) ;
-
 
265
#else
-
 
266
	TYPE p ;
-
 
267
	TYPE s = find_bitfield_type ( t ) ;
-
 
268
	MAKE_type_ptr ( cv_none, s, p ) ;
-
 
269
	s = lvalue_type ( s ) ;
-
 
270
	MAKE_exp_preinc ( s, a, b, op, e ) ;
-
 
271
	MAKE_exp_address ( p, e, e ) ;
-
 
272
	MAKE_exp_add_ptr ( p, e, off, 0, e ) ;
-
 
273
	MAKE_exp_indir ( t, e, e ) ;
-
 
274
#endif
-
 
275
    }
-
 
276
#if LANGUAGE_C
-
 
277
    MAKE_exp_contents ( t, e, e ) ;
316
	MAKE_exp_contents(t, e, e);
278
#endif
317
#endif
279
    return ( e ) ;
318
	return (e);
280
}
319
}
281
 
320
 
282
 
321
 
283
/*
322
/*
284
    CONSTRUCT A PREFIX EXPRESSION
323
    CONSTRUCT A PREFIX EXPRESSION
285
 
324
 
286
    This routine constructs the expressions '++a' and '--a'.  The result is
325
    This routine constructs the expressions '++a' and '--a'.  The result is
287
    an lvalue in C++ but an rvalue in C.
326
    an lvalue in C++ but an rvalue in C.
288
*/
327
*/
289
 
328
 
290
EXP make_prefix_exp
329
EXP
291
    PROTO_N ( ( op, a ) )
-
 
292
    PROTO_T ( int op X EXP a )
330
make_prefix_exp(int op, EXP a)
293
{
331
{
294
    EXP e ;
332
	EXP e;
295
    TYPE ta ;
333
	TYPE ta;
296
    ERROR err ;
334
	ERROR err;
297
    unsigned ca ;
335
	unsigned ca;
298
 
336
 
299
    /* An assignment is a side effect */
337
	/* An assignment is a side effect */
300
    no_side_effects++ ;
338
	no_side_effects++;
301
 
339
 
302
    /* Allow for reference conversions */
340
	/* Allow for reference conversions */
303
    a = convert_reference ( a, REF_NORMAL ) ;
341
	a = convert_reference(a, REF_NORMAL);
304
    ta = DEREF_type ( exp_type ( a ) ) ;
342
	ta = DEREF_type(exp_type(a));
305
    ca = type_category ( &ta ) ;
343
	ca = type_category(&ta);
306
 
344
 
307
    /* Check for overloading */
345
	/* Check for overloading */
308
#if LANGUAGE_CPP
346
#if LANGUAGE_CPP
309
    if ( IS_TYPE_OVERLOAD ( ca ) ) {
347
	if (IS_TYPE_OVERLOAD(ca)) {
310
	if ( overload_depth == 0 ) {
348
		if (overload_depth == 0) {
311
	    /* Overloads as 'operator op ( a )' */
349
			/* Overloads as 'operator op ( a )' */
312
	    e = unary_overload ( op, a ) ;
350
			e = unary_overload(op, a);
313
	    return ( e ) ;
351
			return (e);
314
	}
352
		}
315
	if ( IS_TYPE_CLASS ( ca ) ) goto error_lab ;
353
		if (IS_TYPE_CLASS(ca)) {
-
 
354
			goto error_lab;
316
    }
355
		}
-
 
356
	}
317
#else
357
#else
318
    if ( IS_TYPE_CLASS ( ca ) ) goto error_lab ;
358
	if (IS_TYPE_CLASS(ca)) {
-
 
359
		goto error_lab;
-
 
360
	}
319
#endif
361
#endif
320
 
362
 
321
    /* Operand should be a modifiable lvalue */
363
	/* Operand should be a modifiable lvalue */
322
    err = check_modifiable ( ta, a ) ;
364
	err = check_modifiable(ta, a);
323
    if ( !IS_NULL_err ( err ) ) {
365
	if (!IS_NULL_err(err)) {
324
	err = concat_error ( err, ERR_expr_pre_incr_mod ( op ) ) ;
366
		err = concat_error(err, ERR_expr_pre_incr_mod(op));
325
	report ( crt_loc, err ) ;
367
		report(crt_loc, err);
326
	err = NULL_err ;
368
		err = NULL_err;
-
 
369
	}
-
 
370
 
-
 
371
	/* Operand can be arithmetic ... */
-
 
372
	if (IS_TYPE_ARITH(ca)) {
-
 
373
		EXP c;
-
 
374
		TYPE t;
-
 
375
		OFFSET off = NULL_off;
-
 
376
 
-
 
377
		/* Booleans are weird */
-
 
378
		if (check_int_type(ta, btype_bool)) {
-
 
379
			unsigned v = BOOL_TRUE;
-
 
380
			if (op == lex_plus_Hplus) {
-
 
381
				report(crt_loc,
-
 
382
				       ERR_expr_pre_incr_bool_inc(op, ta));
-
 
383
			} else {
-
 
384
				report(crt_loc,
-
 
385
				       ERR_expr_pre_incr_bool_dec(op, ta));
-
 
386
				v = BOOL_FALSE;
327
    }
387
			}
-
 
388
			c = make_bool_exp(v, exp_int_lit_tag);
-
 
389
			e = make_preinc_exp(ta, a, c, NULL_off, lex_assign);
-
 
390
			return (e);
-
 
391
		}
-
 
392
 
-
 
393
		/* Allow for bitfields */
-
 
394
		if (IS_TYPE_BITF(ca)) {
-
 
395
			off = decons_bitf_exp(&a);
-
 
396
		}
-
 
397
 
-
 
398
		/* Form the result */
-
 
399
		MAKE_exp_dummy(ta, a, LINK_NONE, off, 0, a);
-
 
400
		e = convert_lvalue(a);
-
 
401
		t = DEREF_type(exp_type(e));
-
 
402
		t = promote_type(t);
-
 
403
		e = convert_promote(t, e);
-
 
404
		c = make_unit_exp(t);
-
 
405
		if (op == lex_plus_Hplus) {
-
 
406
			MAKE_exp_plus(t, e, c, e);
-
 
407
		} else {
-
 
408
			MAKE_exp_minus(t, e, c, e);
-
 
409
		}
-
 
410
		e = convert_assign(ta, e, &err);
-
 
411
		if (!IS_NULL_err(err)) {
-
 
412
			err = concat_warning(err, ERR_expr_ass_conv());
-
 
413
			report(crt_loc, err);
-
 
414
		}
-
 
415
		e = make_preinc_exp(ta, a, e, off, op);
-
 
416
		return (e);
-
 
417
	}
328
 
418
 
329
    /* Operand can be arithmetic ... */
419
	/* ... or pointer ... */
330
    if ( IS_TYPE_ARITH ( ca ) ) {
420
	if (IS_TYPE_PTR(ca)) {
-
 
421
		/* Pointer must be to complete object type */
331
	EXP c ;
422
		OFFSET off;
-
 
423
		TYPE t = check_pointer(ta, &err);
-
 
424
		if (!IS_NULL_err(err)) {
-
 
425
			err = concat_error(err, ERR_expr_pre_incr_incompl(op));
-
 
426
			report(crt_loc, err);
332
	TYPE t ;
427
		}
-
 
428
		if (IS_type_top_etc(t)) {
333
	OFFSET off = NULL_off ;
429
			t = type_char;
-
 
430
		}
334
 
431
 
335
	/* Booleans are weird */
-
 
336
	if ( check_int_type ( ta, btype_bool ) ) {
-
 
337
	    unsigned v = BOOL_TRUE ;
-
 
338
	    if ( op == lex_plus_Hplus ) {
-
 
339
		report ( crt_loc, ERR_expr_pre_incr_bool_inc ( op, ta ) ) ;
-
 
340
	    } else {
-
 
341
		report ( crt_loc, ERR_expr_pre_incr_bool_dec ( op, ta ) ) ;
-
 
342
		v = BOOL_FALSE ;
-
 
343
	    }
-
 
344
	    c = make_bool_exp ( v, exp_int_lit_tag ) ;
-
 
345
	    e = make_preinc_exp ( ta, a, c, NULL_off, lex_assign ) ;
-
 
346
	    return ( e ) ;
-
 
347
	}
-
 
348
 
-
 
349
	/* Allow for bitfields */
-
 
350
	if ( IS_TYPE_BITF ( ca ) ) off = decons_bitf_exp ( &a ) ;
-
 
351
 
-
 
352
	/* Form the result */
432
		/* Form the result */
353
	MAKE_exp_dummy ( ta, a, LINK_NONE, off, 0, a ) ;
433
		MAKE_exp_dummy(ta, a, LINK_NONE, NULL_off, 0, a);
354
	e = convert_lvalue ( a ) ;
434
		e = convert_lvalue(a);
355
	t = DEREF_type ( exp_type ( e ) ) ;
435
		if (!IS_type_ptr(ta)) {
356
	t = promote_type ( t ) ;
436
			ta = DEREF_type(exp_type(e));
-
 
437
		}
357
	e = convert_promote ( t, e ) ;
438
		MAKE_off_type(t, off);
358
	c = make_unit_exp ( t ) ;
-
 
359
	if ( op == lex_plus_Hplus ) {
439
		if (op == lex_minus_Hminus) {
360
	    MAKE_exp_plus ( t, e, c, e ) ;
-
 
361
	} else {
-
 
362
	    MAKE_exp_minus ( t, e, c, e ) ;
440
			MAKE_off_negate(off, off);
363
	}
441
		}
364
	e = convert_assign ( ta, e, &err ) ;
442
		e = make_add_ptr(ta, e, off);
365
	if ( !IS_NULL_err ( err ) ) {
-
 
366
	    err = concat_warning ( err, ERR_expr_ass_conv () ) ;
443
		e = make_preinc_exp(ta, a, e, NULL_off, op);
367
	    report ( crt_loc, err ) ;
444
		return (e);
368
	}
445
	}
369
	e = make_preinc_exp ( ta, a, e, off, op ) ;
-
 
370
	return ( e ) ;
-
 
371
    }
-
 
372
 
-
 
373
    /* ... or pointer ... */
-
 
374
    if ( IS_TYPE_PTR ( ca ) ) {
-
 
375
	/* Pointer must be to complete object type */
-
 
376
	OFFSET off ;
-
 
377
	TYPE t = check_pointer ( ta, &err ) ;
-
 
378
	if ( !IS_NULL_err ( err ) ) {
-
 
379
	    err = concat_error ( err, ERR_expr_pre_incr_incompl ( op ) ) ;
-
 
380
	    report ( crt_loc, err ) ;
-
 
381
	}
-
 
382
	if ( IS_type_top_etc ( t ) ) t = type_char ;
-
 
383
 
-
 
384
	/* Form the result */
-
 
385
	MAKE_exp_dummy ( ta, a, LINK_NONE, NULL_off, 0, a ) ;
-
 
386
	e = convert_lvalue ( a ) ;
-
 
387
	if ( !IS_type_ptr ( ta ) ) ta = DEREF_type ( exp_type ( e ) ) ;
-
 
388
	MAKE_off_type ( t, off ) ;
-
 
389
	if ( op == lex_minus_Hminus ) MAKE_off_negate ( off, off ) ;
-
 
390
	e = make_add_ptr ( ta, e, off ) ;
-
 
391
	e = make_preinc_exp ( ta, a, e, NULL_off, op ) ;
-
 
392
	return ( e ) ;
-
 
393
    }
-
 
394
 
446
 
395
    /* ... and nothing else */
447
	/* ... and nothing else */
396
    error_lab : {
448
error_lab:
397
	if ( !IS_TYPE_ERROR ( ca ) ) {
449
	if (!IS_TYPE_ERROR(ca)) {
398
	    report ( crt_loc, ERR_expr_pre_incr_op ( op, ta ) ) ;
450
		report(crt_loc, ERR_expr_pre_incr_op(op, ta));
399
	}
451
	}
400
	e = make_error_exp ( LANGUAGE_CPP ) ;
452
	e = make_error_exp(LANGUAGE_CPP);
401
	return ( e ) ;
453
	return (e);
402
    }
-
 
403
}
454
}
404
 
455
 
405
 
456
 
406
/*
457
/*
407
    CONSTRUCT AN ASSIGNMENT EXPRESSION
458
    CONSTRUCT AN ASSIGNMENT EXPRESSION
Line 409... Line 460...
409
    This routine constructs the expression 'a = b'.  If c is true then
460
    This routine constructs the expression 'a = b'.  If c is true then
410
    assignment of classes is done directly rather than via an assignment
461
    assignment of classes is done directly rather than via an assignment
411
    operator.  The result is an lvalue in C++ but an rvalue in C.
462
    operator.  The result is an lvalue in C++ but an rvalue in C.
412
*/
463
*/
413
 
464
 
414
EXP make_assign_exp
465
EXP
415
    PROTO_N ( ( a, b, c ) )
-
 
416
    PROTO_T ( EXP a X EXP b X int c )
466
make_assign_exp(EXP a, EXP b, int c)
417
{
467
{
418
    EXP e ;
468
	EXP e;
419
    ERROR err ;
469
	ERROR err;
420
    TYPE ta, tb ;
470
	TYPE ta, tb;
421
    unsigned ca, cb ;
471
	unsigned ca, cb;
422
    int to_class = 0 ;
472
	int to_class = 0;
423
    int op = lex_assign ;
473
	int op = lex_assign;
424
    OFFSET off = NULL_off ;
474
	OFFSET off = NULL_off;
425
 
475
 
426
    /* An assignment is a side effect */
476
	/* An assignment is a side effect */
427
    no_side_effects++ ;
477
	no_side_effects++;
428
 
478
 
429
    /* Apply reference conversion on first operand */
479
	/* Apply reference conversion on first operand */
430
    a = convert_reference ( a, REF_NORMAL ) ;
480
	a = convert_reference(a, REF_NORMAL);
431
    ta = DEREF_type ( exp_type ( a ) ) ;
481
	ta = DEREF_type(exp_type(a));
432
    ca = type_category ( &ta ) ;
482
	ca = type_category(&ta);
433
 
483
 
434
    /* Apply reference conversion on second operand */
484
	/* Apply reference conversion on second operand */
435
    b = convert_reference ( b, REF_ASSIGN ) ;
485
	b = convert_reference(b, REF_ASSIGN);
436
    tb = DEREF_type ( exp_type ( b ) ) ;
486
	tb = DEREF_type(exp_type(b));
437
    cb = type_category ( &tb ) ;
487
	cb = type_category(&tb);
438
 
488
 
439
    /* Check for template parameters */
489
	/* Check for template parameters */
440
#if LANGUAGE_CPP
490
#if LANGUAGE_CPP
441
    if ( IS_TYPE_TEMPL ( ca ) || IS_TYPE_TEMPL ( cb ) ) {
491
	if (IS_TYPE_TEMPL(ca) || IS_TYPE_TEMPL(cb)) {
442
	if ( overload_depth == 0 ) {
492
		if (overload_depth == 0) {
443
	    e = binary_overload ( op, a, b ) ;
493
			e = binary_overload(op, a, b);
444
	    return ( e ) ;
494
			return (e);
445
	}
495
		}
446
    }
496
	}
447
#endif
497
#endif
448
 
498
 
449
    /* Check for overloading (classes only) */
499
	/* Check for overloading (classes only) */
450
    if ( IS_TYPE_CLASS ( ca ) ) {
500
	if (IS_TYPE_CLASS(ca)) {
451
#if LANGUAGE_CPP
501
#if LANGUAGE_CPP
452
	if ( c == 0 ) {
502
		if (c == 0) {
453
	    if ( overload_depth == 0 ) {
503
			if (overload_depth == 0) {
454
		e = binary_overload ( op, a, b ) ;
504
				e = binary_overload(op, a, b);
455
		return ( e ) ;
505
				return (e);
456
	    }
506
			}
457
	    if ( !IS_TYPE_ERROR ( cb ) ) {
507
			if (!IS_TYPE_ERROR(cb)) {
458
		/* Find reason for failure */
508
				/* Find reason for failure */
459
		err = check_incomplete ( ta ) ;
509
				err = check_incomplete(ta);
460
		if ( IS_NULL_err ( err ) && IS_type_compound ( ta ) ) {
510
				if (IS_NULL_err(err) && IS_type_compound(ta)) {
461
		    CLASS_TYPE ct ;
511
					CLASS_TYPE ct;
462
		    IDENTIFIER id ;
512
					IDENTIFIER id;
463
		    ct = DEREF_ctype ( type_compound_defn ( ta ) ) ;
513
					ct = DEREF_ctype(type_compound_defn(ta));
464
		    id = find_operator ( ct, op ) ;
514
					id = find_operator(ct, op);
465
		    if ( !IS_NULL_id ( id ) ) {
515
					if (!IS_NULL_id(id)) {
466
			err = ERR_over_match_viable_none ( id ) ;
516
						err = ERR_over_match_viable_none(id);
467
		    }
517
					}
-
 
518
				}
-
 
519
				err = concat_error(err, ERR_expr_ass_op(op, ta, tb));
-
 
520
				report(crt_loc, err);
-
 
521
			}
-
 
522
			e = make_error_exp(LANGUAGE_CPP);
-
 
523
			return (e);
468
		}
524
		}
469
		err = concat_error ( err, ERR_expr_ass_op ( op, ta, tb ) ) ;
-
 
470
		report ( crt_loc, err ) ;
-
 
471
	    }
-
 
472
	    e = make_error_exp ( LANGUAGE_CPP ) ;
-
 
473
	    return ( e ) ;
-
 
474
	}
-
 
475
#else
525
#else
476
	UNUSED ( c ) ;
526
		UNUSED(c);
477
	UNUSED ( cb ) ;
527
		UNUSED(cb);
478
#endif
528
#endif
479
	to_class = 1 ;
529
		to_class = 1;
480
    }
530
	}
481
 
531
 
482
    /* First operand should be a modifiable lvalue */
532
	/* First operand should be a modifiable lvalue */
483
    err = check_modifiable ( ta, a ) ;
533
	err = check_modifiable(ta, a);
484
    if ( !IS_NULL_err ( err ) ) {
534
	if (!IS_NULL_err(err)) {
485
	err = concat_error ( err, ERR_expr_ass_mod ( op ) ) ;
535
		err = concat_error(err, ERR_expr_ass_mod(op));
486
	report ( crt_loc, err ) ;
536
		report(crt_loc, err);
487
    }
537
	}
488
 
538
 
489
    /* Do operand conversion */
539
	/* Do operand conversion */
490
    err = NULL_err ;
540
	err = NULL_err;
491
    if ( to_class ) {
541
	if (to_class) {
492
	b = convert_none ( b ) ;
542
		b = convert_none(b);
493
	b = convert_class ( ta, b, &err ) ;
543
		b = convert_class(ta, b, &err);
494
	b = remove_temporary ( b, a ) ;
544
		b = remove_temporary(b, a);
495
    } else {
545
	} else {
496
	b = convert_assign ( ta, b, &err ) ;
546
		b = convert_assign(ta, b, &err);
497
    }
547
	}
498
    if ( !IS_NULL_err ( err ) ) {
548
	if (!IS_NULL_err(err)) {
499
	err = concat_warning ( err, ERR_expr_ass_conv () ) ;
549
		err = concat_warning(err, ERR_expr_ass_conv());
500
	report ( crt_loc, err ) ;
550
		report(crt_loc, err);
501
    }
551
	}
502
 
552
 
503
    /* Construct the result */
553
	/* Construct the result */
504
    if ( IS_type_bitfield ( ta ) ) {
554
	if (IS_type_bitfield(ta)) {
505
	off = decons_bitf_exp ( &a ) ;
555
		off = decons_bitf_exp(&a);
506
	MAKE_exp_dummy ( ta, a, LINK_NONE, off, 0, a ) ;
556
		MAKE_exp_dummy(ta, a, LINK_NONE, off, 0, a);
507
    }
557
	}
508
    e = make_preinc_exp ( ta, a, b, off, op ) ;
558
	e = make_preinc_exp(ta, a, b, off, op);
509
    return ( e ) ;
559
	return (e);
510
}
560
}
511
 
561
 
512
 
562
 
513
/*
563
/*
514
    CONSTRUCT A BECOMES EXPRESSION
564
    CONSTRUCT A BECOMES EXPRESSION
Line 516... Line 566...
516
    This routine constructs the expression 'a op b' where op is one of the
566
    This routine constructs the expression 'a op b' where op is one of the
517
    assignment operators, '*=', '/=' etc.  The result is an lvalue in
567
    assignment operators, '*=', '/=' etc.  The result is an lvalue in
518
    C++, but an rvalue in C.
568
    C++, but an rvalue in C.
519
*/
569
*/
520
 
570
 
521
EXP make_become_exp
571
EXP
522
    PROTO_N ( ( op, a, b ) )
-
 
523
    PROTO_T ( int op X EXP a X EXP b )
572
make_become_exp(int op, EXP a, EXP b)
524
{
573
{
525
    EXP e ;
574
	EXP e;
526
    EXP d ;
575
	EXP d;
527
    TYPE td ;
576
	TYPE td;
528
    ERROR err ;
577
	ERROR err;
529
    TYPE ta, tb ;
578
	TYPE ta, tb;
530
    unsigned tag ;
579
	unsigned tag;
531
    unsigned ca, cb ;
580
	unsigned ca, cb;
532
    OFFSET off = NULL_off ;
581
	OFFSET off = NULL_off;
533
 
582
 
534
    /* An assignment is a side effect */
583
	/* An assignment is a side effect */
535
    no_side_effects++ ;
584
	no_side_effects++;
536
 
585
 
537
    /* Apply reference conversion on first operand */
586
	/* Apply reference conversion on first operand */
538
    a = convert_reference ( a, REF_NORMAL ) ;
587
	a = convert_reference(a, REF_NORMAL);
539
    ta = DEREF_type ( exp_type ( a ) ) ;
588
	ta = DEREF_type(exp_type(a));
540
    ca = type_category ( &ta ) ;
589
	ca = type_category(&ta);
541
 
590
 
542
    /* Apply reference conversion on second operand */
591
	/* Apply reference conversion on second operand */
543
    b = convert_reference ( b, REF_NORMAL ) ;
592
	b = convert_reference(b, REF_NORMAL);
544
    tb = DEREF_type ( exp_type ( b ) ) ;
593
	tb = DEREF_type(exp_type(b));
545
    cb = type_category ( &tb ) ;
594
	cb = type_category(&tb);
546
 
595
 
547
    /* Allow for overloading */
596
	/* Allow for overloading */
548
#if LANGUAGE_CPP
597
#if LANGUAGE_CPP
549
    if ( IS_TYPE_OVERLOAD ( ca ) || IS_TYPE_OVERLOAD ( cb ) ) {
598
	if (IS_TYPE_OVERLOAD(ca) || IS_TYPE_OVERLOAD(cb)) {
550
	if ( overload_depth == 0 ) {
599
		if (overload_depth == 0) {
551
	    e = binary_overload ( op, a, b ) ;
600
			e = binary_overload(op, a, b);
552
	    return ( e ) ;
601
			return (e);
553
	}
602
		}
554
	if ( IS_TYPE_CLASS ( ca ) ) goto error_lab ;
603
		if (IS_TYPE_CLASS(ca)) {
-
 
604
			goto error_lab;
555
    }
605
		}
-
 
606
	}
556
#else
607
#else
557
    if ( IS_TYPE_CLASS ( ca ) ) goto error_lab ;
608
	if (IS_TYPE_CLASS(ca)) {
-
 
609
		goto error_lab;
-
 
610
	}
558
#endif
611
#endif
559
 
612
 
560
    /* First operand should be a modifiable lvalue */
613
	/* First operand should be a modifiable lvalue */
561
    err = check_modifiable ( ta, a ) ;
614
	err = check_modifiable(ta, a);
562
    if ( !IS_NULL_err ( err ) ) {
615
	if (!IS_NULL_err(err)) {
563
	err = concat_error ( err, ERR_expr_ass_mod ( op ) ) ;
616
		err = concat_error(err, ERR_expr_ass_mod(op));
564
	report ( crt_loc, err ) ;
617
		report(crt_loc, err);
565
	err = NULL_err ;
618
		err = NULL_err;
566
    }
619
	}
567
 
620
 
568
    /* Allow for bitfields */
621
	/* Allow for bitfields */
-
 
622
	if (IS_TYPE_BITF(ca)) {
569
    if ( IS_TYPE_BITF ( ca ) ) off = decons_bitf_exp ( &a ) ;
623
		off = decons_bitf_exp(&a);
-
 
624
	}
570
 
625
 
571
    /* Introduce identity for assignment variable */
626
	/* Introduce identity for assignment variable */
572
    td = ta ;
627
	td = ta;
573
    MAKE_exp_dummy ( td, a, LINK_NONE, off, 0, d ) ;
628
	MAKE_exp_dummy(td, a, LINK_NONE, off, 0, d);
574
    a = convert_lvalue ( d ) ;
629
	a = convert_lvalue(d);
575
    ta = DEREF_type ( exp_type ( a ) ) ;
630
	ta = DEREF_type(exp_type(a));
576
    ca = type_category ( &ta ) ;
631
	ca = type_category(&ta);
577
 
632
 
578
    /* Do lvalue conversions */
633
	/* Do lvalue conversions */
579
    if ( IS_TYPE_ADDRESS ( cb ) ) {
634
	if (IS_TYPE_ADDRESS(cb)) {
580
	b = convert_lvalue ( b ) ;
635
		b = convert_lvalue(b);
581
	tb = DEREF_type ( exp_type ( b ) ) ;
636
		tb = DEREF_type(exp_type(b));
582
	cb = type_category ( &tb ) ;
637
		cb = type_category(&tb);
583
    }
638
	}
584
 
639
 
585
    /* Weed out booleans immediately */
640
	/* Weed out booleans immediately */
586
    if ( IS_TYPE_INT ( ca ) && check_int_type ( ta, btype_bool ) ) {
641
	if (IS_TYPE_INT(ca) && check_int_type(ta, btype_bool)) {
587
	report ( crt_loc, ERR_expr_ass_op ( op, ta, tb ) ) ;
642
		report(crt_loc, ERR_expr_ass_op(op, ta, tb));
588
	e = make_error_exp ( LANGUAGE_CPP ) ;
643
		e = make_error_exp(LANGUAGE_CPP);
589
	return ( e ) ;
644
		return (e);
590
    }
645
	}
591
 
646
 
592
    /* Find the operation type */
647
	/* Find the operation type */
593
    switch ( op ) {
648
	switch (op) {
594
	case lex_and_Heq_H1 : tag = exp_and_tag ; goto integral_lab ;
649
	case lex_and_Heq_H1:
595
	case lex_div_Heq : tag = exp_div_tag ; goto arithmetic_lab ;
650
		tag = exp_and_tag;
-
 
651
		goto integral_lab;
596
	case lex_lshift_Heq : tag = exp_lshift_tag ; goto shift_lab ;
652
	case lex_div_Heq:
597
	case lex_minus_Heq : tag = exp_minus_tag ; goto pointer_lab ;
653
		tag = exp_div_tag;
598
	case lex_or_Heq_H1 : tag = exp_or_tag ; goto integral_lab ;
654
		goto arithmetic_lab;
599
	case lex_plus_Heq : tag = exp_plus_tag ; goto pointer_lab ;
655
	case lex_lshift_Heq:
600
	case lex_rem_Heq : tag = exp_rem_tag ; goto integral_lab ;
656
		tag = exp_lshift_tag;
601
	case lex_rshift_Heq : tag = exp_rshift_tag ; goto shift_lab ;
657
		goto shift_lab;
602
	case lex_star_Heq : tag = exp_mult_tag ; goto arithmetic_lab ;
658
	case lex_minus_Heq:
603
	case lex_xor_Heq_H1 : tag = exp_xor_tag ; goto integral_lab ;
659
		tag = exp_minus_tag;
604
	default : goto error_lab ;
660
		goto pointer_lab;
-
 
661
	case lex_or_Heq_H1:
605
    }
662
		tag = exp_or_tag;
606
 
-
 
607
    integral_lab : {
663
		goto integral_lab;
608
	/* Integral operations */
664
	case lex_plus_Heq:
609
	if ( IS_TYPE_INT ( ca ) && IS_TYPE_INT ( cb ) ) {
665
		tag = exp_plus_tag;
610
	    TYPE t = arith_type ( ta, tb, a, b ) ;
666
		goto pointer_lab;
-
 
667
	case lex_rem_Heq:
611
	    a = convert_arith ( t, a, op, 1 ) ;
668
		tag = exp_rem_tag;
612
	    b = convert_arith ( t, b, op, 2 ) ;
669
		goto integral_lab;
613
	    if ( op == lex_rem_Heq ) {
670
	case lex_rshift_Heq:
614
		IGNORE check_div_exp ( op, a, b ) ;
671
		tag = exp_rshift_tag;
615
	    }
672
		goto shift_lab;
-
 
673
	case lex_star_Heq:
616
	    MAKE_exp_plus_etc ( tag, t, a, b, e ) ;
674
		tag = exp_mult_tag;
617
	    e = convert_assign ( td, e, &err ) ;
675
		goto arithmetic_lab;
618
	    if ( !IS_NULL_err ( err ) ) {
676
	case lex_xor_Heq_H1:
619
		err = concat_warning ( err, ERR_expr_ass_conv () ) ;
677
		tag = exp_xor_tag;
620
		report ( crt_loc, err ) ;
678
		goto integral_lab;
621
	    }
679
	default:
622
	    e = make_preinc_exp ( td, d, e, off, op ) ;
-
 
623
	    return ( e ) ;
680
		goto error_lab;
624
	}
681
	}
625
	goto error_lab ;
-
 
626
    }
-
 
627
 
682
 
628
    arithmetic_lab : {
683
integral_lab:
629
	/* Arithmetic operations */
684
	/* Integral operations */
630
	if ( IS_TYPE_ARITH ( ca ) && IS_TYPE_ARITH ( cb ) ) {
685
	if (IS_TYPE_INT(ca) && IS_TYPE_INT(cb)) {
631
	    TYPE t = arith_type ( ta, tb, a, b ) ;
686
		TYPE t = arith_type(ta, tb, a, b);
632
	    a = convert_arith ( t, a, op, 1 ) ;
687
		a = convert_arith(t, a, op, 1);
633
	    b = convert_arith ( t, b, op, 2 ) ;
688
		b = convert_arith(t, b, op, 2);
634
	    if ( op == lex_div_Heq ) {
689
		if (op == lex_rem_Heq) {
635
		IGNORE check_div_exp ( op, a, b ) ;
690
			IGNORE check_div_exp(op, a, b);
636
	    }
691
		}
637
	    MAKE_exp_plus_etc ( tag, t, a, b, e ) ;
692
		MAKE_exp_plus_etc(tag, t, a, b, e);
638
	    e = convert_assign ( td, e, &err ) ;
693
		e = convert_assign(td, e, &err);
639
	    if ( !IS_NULL_err ( err ) ) {
694
		if (!IS_NULL_err(err)) {
640
		err = concat_warning ( err, ERR_expr_ass_conv () ) ;
695
			err = concat_warning(err, ERR_expr_ass_conv());
641
		report ( crt_loc, err ) ;
696
			report(crt_loc, err);
642
	    }
697
		}
643
	    e = make_preinc_exp ( td, d, e, off, op ) ;
698
		e = make_preinc_exp(td, d, e, off, op);
644
	    return ( e ) ;
699
		return (e);
645
	}
700
	}
646
	goto error_lab ;
701
	goto error_lab;
-
 
702
 
-
 
703
arithmetic_lab:
-
 
704
	/* Arithmetic operations */
-
 
705
	if (IS_TYPE_ARITH(ca) && IS_TYPE_ARITH(cb)) {
-
 
706
		TYPE t = arith_type(ta, tb, a, b);
-
 
707
		a = convert_arith(t, a, op, 1);
-
 
708
		b = convert_arith(t, b, op, 2);
-
 
709
		if (op == lex_div_Heq) {
-
 
710
			IGNORE check_div_exp(op, a, b);
647
    }
711
		}
-
 
712
		MAKE_exp_plus_etc(tag, t, a, b, e);
-
 
713
		e = convert_assign(td, e, &err);
-
 
714
		if (!IS_NULL_err(err)) {
-
 
715
			err = concat_warning(err, ERR_expr_ass_conv());
-
 
716
			report(crt_loc, err);
-
 
717
		}
-
 
718
		e = make_preinc_exp(td, d, e, off, op);
-
 
719
		return (e);
-
 
720
	}
-
 
721
	goto error_lab;
648
 
722
 
649
    shift_lab : {
723
shift_lab:
650
	/* Shift operations */
724
	/* Shift operations */
651
	if ( IS_TYPE_INT ( ca ) && IS_TYPE_INT ( cb ) ) {
725
	if (IS_TYPE_INT(ca) && IS_TYPE_INT(cb)) {
652
	    TYPE pta = promote_type ( ta ) ;
726
		TYPE pta = promote_type(ta);
653
	    TYPE ptb = promote_type ( tb ) ;
727
		TYPE ptb = promote_type(tb);
654
	    a = convert_promote ( pta, a ) ;
728
		a = convert_promote(pta, a);
655
	    b = convert_promote ( ptb, b ) ;
729
		b = convert_promote(ptb, b);
656
	    IGNORE check_shift_exp ( op, pta, a, b ) ;
730
		IGNORE check_shift_exp(op, pta, a, b);
657
	    MAKE_exp_plus_etc ( tag, pta, a, b, e ) ;
731
		MAKE_exp_plus_etc(tag, pta, a, b, e);
658
	    e = convert_assign ( td, e, &err ) ;
732
		e = convert_assign(td, e, &err);
659
	    if ( !IS_NULL_err ( err ) ) {
733
		if (!IS_NULL_err(err)) {
660
		err = concat_warning ( err, ERR_expr_ass_conv () ) ;
734
			err = concat_warning(err, ERR_expr_ass_conv());
661
		report ( crt_loc, err ) ;
735
			report(crt_loc, err);
662
	    }
736
		}
663
	    e = make_preinc_exp ( td, d, e, off, op ) ;
737
		e = make_preinc_exp(td, d, e, off, op);
664
	    return ( e ) ;
738
		return (e);
665
	}
739
	}
666
	goto error_lab ;
740
	goto error_lab;
667
    }
-
 
668
 
741
 
669
    pointer_lab : {
742
pointer_lab:
670
	/* Pointer or arithmetic operations */
743
	/* Pointer or arithmetic operations */
671
	if ( IS_TYPE_PTR ( ca ) && IS_TYPE_INT ( cb ) ) {
744
	if (IS_TYPE_PTR(ca) && IS_TYPE_INT(cb)) {
672
	    OFFSET off1 ;
745
		OFFSET off1;
673
	    int neg = 0 ;
746
		int neg = 0;
674
	    TYPE t = check_pointer ( ta, &err ) ;
747
		TYPE t = check_pointer(ta, &err);
675
	    if ( !IS_NULL_err ( err ) ) {
748
		if (!IS_NULL_err(err)) {
676
		err = concat_error ( err, ERR_expr_ass_incompl ( op ) ) ;
749
			err = concat_error(err, ERR_expr_ass_incompl(op));
677
		report ( crt_loc, err ) ;
750
			report(crt_loc, err);
678
	    }
751
		}
679
	    if ( op == lex_minus_Heq ) neg = 1 ;
752
		if (op == lex_minus_Heq) {
-
 
753
			neg = 1;
-
 
754
		}
680
	    off1 = make_off_mult ( t, b, neg ) ;
755
		off1 = make_off_mult(t, b, neg);
681
	    e = make_add_ptr ( ta, a, off1 ) ;
756
		e = make_add_ptr(ta, a, off1);
682
	    e = make_preinc_exp ( td, d, e, NULL_off, op ) ;
757
		e = make_preinc_exp(td, d, e, NULL_off, op);
683
	    return ( e ) ;
758
		return (e);
684
	}
759
	}
685
	goto arithmetic_lab ;
760
	goto arithmetic_lab;
686
    }
-
 
687
 
761
 
688
    error_lab : {
762
error_lab:
689
	/* Bad operations */
763
	/* Bad operations */
690
	if ( !IS_TYPE_ERROR ( ca ) && !IS_TYPE_ERROR ( cb ) ) {
764
	if (!IS_TYPE_ERROR(ca) && !IS_TYPE_ERROR(cb)) {
691
	    report ( crt_loc, ERR_expr_ass_op ( op, ta, tb ) ) ;
765
		report(crt_loc, ERR_expr_ass_op(op, ta, tb));
692
	}
766
	}
693
	e = make_error_exp ( LANGUAGE_CPP ) ;
767
	e = make_error_exp(LANGUAGE_CPP);
694
	return ( e ) ;
768
	return (e);
695
    }
-
 
696
}
769
}