]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/cp/semantics.c
c-common.def (GOTO_STMT, LABEL_STMT): Remove.
[thirdparty/gcc.git] / gcc / cp / semantics.c
CommitLineData
ad321293
MM
1/* Perform the semantic phase of parsing, i.e., the process of
2 building tree structure, checking semantic consistency, and
3 building RTL. These routines are used both during actual parsing
4 and during the instantiation of template functions.
5
dbbf88d1 6 Copyright (C) 1998, 1999, 2000, 2001, 2002,
572c2b17 7 2003, 2004 Free Software Foundation, Inc.
ad321293
MM
8 Written by Mark Mitchell (mmitchell@usa.net) based on code found
9 formerly in parse.y and pt.c.
10
f5adbb8d 11 This file is part of GCC.
ad321293 12
f5adbb8d 13 GCC is free software; you can redistribute it and/or modify it
ad321293
MM
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
16 any later version.
17
f5adbb8d 18 GCC is distributed in the hope that it will be useful, but
ad321293
MM
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
f5adbb8d 24 along with GCC; see the file COPYING. If not, write to the Free
ad321293
MM
25 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 02111-1307, USA. */
27
28#include "config.h"
8d052bc7 29#include "system.h"
4977bab6
ZW
30#include "coretypes.h"
31#include "tm.h"
ad321293
MM
32#include "tree.h"
33#include "cp-tree.h"
25af8512 34#include "tree-inline.h"
6de9cd9a 35#include "tree-mudflap.h"
ad321293
MM
36#include "except.h"
37#include "lex.h"
12027a89 38#include "toplev.h"
84df082b 39#include "flags.h"
d9b2d9da 40#include "rtl.h"
d6684bc8 41#include "expr.h"
225ff119 42#include "output.h"
ea11ca7e 43#include "timevar.h"
2b85879e 44#include "debug.h"
6de9cd9a 45#include "diagnostic.h"
8cd2462c 46#include "cgraph.h"
325c3691 47#include "tree-iterator.h"
ad321293
MM
48
49/* There routines provide a modular interface to perform many parsing
50 operations. They may therefore be used during actual parsing, or
51 during template instantiation, which may be regarded as a
52 degenerate form of parsing. Since the current g++ parser is
53 lacking in several respects, and will be reimplemented, we are
54 attempting to move most code that is not directly related to
55 parsing into this file; that will make implementing the new parser
56 much easier since it will be able to make use of these routines. */
57
3a978d72
NN
58static tree maybe_convert_cond (tree);
59static tree simplify_aggr_init_exprs_r (tree *, int *, void *);
60static void emit_associated_thunks (tree);
6de9cd9a 61static tree finalize_nrv_r (tree *, int *, void *);
4985cde3 62
558475f0 63
8d241e0b
KL
64/* Deferred Access Checking Overview
65 ---------------------------------
66
67 Most C++ expressions and declarations require access checking
68 to be performed during parsing. However, in several cases,
69 this has to be treated differently.
70
71 For member declarations, access checking has to be deferred
72 until more information about the declaration is known. For
73 example:
74
75 class A {
76 typedef int X;
77 public:
78 X f();
79 };
80
81 A::X A::f();
82 A::X g();
83
84 When we are parsing the function return type `A::X', we don't
85 really know if this is allowed until we parse the function name.
86
87 Furthermore, some contexts require that access checking is
88 never performed at all. These include class heads, and template
89 instantiations.
90
91 Typical use of access checking functions is described here:
92
93 1. When we enter a context that requires certain access checking
94 mode, the function `push_deferring_access_checks' is called with
95 DEFERRING argument specifying the desired mode. Access checking
96 may be performed immediately (dk_no_deferred), deferred
97 (dk_deferred), or not performed (dk_no_check).
98
99 2. When a declaration such as a type, or a variable, is encountered,
100 the function `perform_or_defer_access_check' is called. It
101 maintains a TREE_LIST of all deferred checks.
102
103 3. The global `current_class_type' or `current_function_decl' is then
104 setup by the parser. `enforce_access' relies on these information
105 to check access.
106
107 4. Upon exiting the context mentioned in step 1,
108 `perform_deferred_access_checks' is called to check all declaration
109 stored in the TREE_LIST. `pop_deferring_access_checks' is then
110 called to restore the previous access checking mode.
111
112 In case of parsing error, we simply call `pop_deferring_access_checks'
113 without `perform_deferred_access_checks'. */
114
cf22909c
KL
115/* Data for deferred access checking. */
116static GTY(()) deferred_access *deferred_access_stack;
117static GTY(()) deferred_access *deferred_access_free_list;
118
119/* Save the current deferred access states and start deferred
120 access checking iff DEFER_P is true. */
121
572c2b17
AP
122void
123push_deferring_access_checks (deferring_kind deferring)
cf22909c
KL
124{
125 deferred_access *d;
126
78757caa
KL
127 /* For context like template instantiation, access checking
128 disabling applies to all nested context. */
129 if (deferred_access_stack
130 && deferred_access_stack->deferring_access_checks_kind == dk_no_check)
131 deferring = dk_no_check;
132
cf22909c
KL
133 /* Recycle previously used free store if available. */
134 if (deferred_access_free_list)
135 {
136 d = deferred_access_free_list;
137 deferred_access_free_list = d->next;
138 }
139 else
c68b0a84 140 d = ggc_alloc (sizeof (deferred_access));
cf22909c
KL
141
142 d->next = deferred_access_stack;
143 d->deferred_access_checks = NULL_TREE;
8d241e0b 144 d->deferring_access_checks_kind = deferring;
cf22909c
KL
145 deferred_access_stack = d;
146}
147
148/* Resume deferring access checks again after we stopped doing
149 this previously. */
150
572c2b17
AP
151void
152resume_deferring_access_checks (void)
cf22909c 153{
8d241e0b
KL
154 if (deferred_access_stack->deferring_access_checks_kind == dk_no_deferred)
155 deferred_access_stack->deferring_access_checks_kind = dk_deferred;
cf22909c
KL
156}
157
158/* Stop deferring access checks. */
159
572c2b17
AP
160void
161stop_deferring_access_checks (void)
cf22909c 162{
8d241e0b
KL
163 if (deferred_access_stack->deferring_access_checks_kind == dk_deferred)
164 deferred_access_stack->deferring_access_checks_kind = dk_no_deferred;
cf22909c
KL
165}
166
167/* Discard the current deferred access checks and restore the
168 previous states. */
169
572c2b17
AP
170void
171pop_deferring_access_checks (void)
cf22909c
KL
172{
173 deferred_access *d = deferred_access_stack;
174 deferred_access_stack = d->next;
175
176 /* Remove references to access checks TREE_LIST. */
177 d->deferred_access_checks = NULL_TREE;
178
179 /* Store in free list for later use. */
180 d->next = deferred_access_free_list;
181 deferred_access_free_list = d;
182}
183
184/* Returns a TREE_LIST representing the deferred checks.
185 The TREE_PURPOSE of each node is the type through which the
186 access occurred; the TREE_VALUE is the declaration named.
187 */
188
572c2b17
AP
189tree
190get_deferred_access_checks (void)
cf22909c
KL
191{
192 return deferred_access_stack->deferred_access_checks;
193}
194
195/* Take current deferred checks and combine with the
196 previous states if we also defer checks previously.
197 Otherwise perform checks now. */
198
572c2b17
AP
199void
200pop_to_parent_deferring_access_checks (void)
cf22909c
KL
201{
202 tree deferred_check = get_deferred_access_checks ();
203 deferred_access *d1 = deferred_access_stack;
204 deferred_access *d2 = deferred_access_stack->next;
205 deferred_access *d3 = deferred_access_stack->next->next;
206
207 /* Temporary swap the order of the top two states, just to make
208 sure the garbage collector will not reclaim the memory during
209 processing below. */
210 deferred_access_stack = d2;
211 d2->next = d1;
212 d1->next = d3;
213
214 for ( ; deferred_check; deferred_check = TREE_CHAIN (deferred_check))
215 /* Perform deferred check if required. */
216 perform_or_defer_access_check (TREE_PURPOSE (deferred_check),
217 TREE_VALUE (deferred_check));
218
219 deferred_access_stack = d1;
220 d1->next = d2;
221 d2->next = d3;
222 pop_deferring_access_checks ();
223}
224
25903d03
KL
225/* Perform the deferred access checks.
226
227 After performing the checks, we still have to keep the list
228 `deferred_access_stack->deferred_access_checks' since we may want
229 to check access for them again later in a different context.
230 For example:
231
232 class A {
233 typedef int X;
234 static X a;
235 };
236 A::X A::a, x; // No error for `A::a', error for `x'
237
238 We have to perform deferred access of `A::X', first with `A::a',
239 next with `x'. */
cf22909c 240
572c2b17
AP
241void
242perform_deferred_access_checks (void)
cf22909c
KL
243{
244 tree deferred_check;
245 for (deferred_check = deferred_access_stack->deferred_access_checks;
246 deferred_check;
247 deferred_check = TREE_CHAIN (deferred_check))
248 /* Check access. */
249 enforce_access (TREE_PURPOSE (deferred_check),
250 TREE_VALUE (deferred_check));
cf22909c
KL
251}
252
253/* Defer checking the accessibility of DECL, when looked up in
6df5158a 254 BINFO. */
cf22909c 255
572c2b17
AP
256void
257perform_or_defer_access_check (tree binfo, tree decl)
cf22909c
KL
258{
259 tree check;
260
6df5158a
NS
261 my_friendly_assert (TREE_CODE (binfo) == TREE_VEC, 20030623);
262
cf22909c 263 /* If we are not supposed to defer access checks, just check now. */
8d241e0b 264 if (deferred_access_stack->deferring_access_checks_kind == dk_no_deferred)
cf22909c 265 {
6df5158a 266 enforce_access (binfo, decl);
cf22909c
KL
267 return;
268 }
8d241e0b
KL
269 /* Exit if we are in a context that no access checking is performed. */
270 else if (deferred_access_stack->deferring_access_checks_kind == dk_no_check)
271 return;
cf22909c
KL
272
273 /* See if we are already going to perform this check. */
274 for (check = deferred_access_stack->deferred_access_checks;
275 check;
276 check = TREE_CHAIN (check))
6df5158a 277 if (TREE_VALUE (check) == decl && TREE_PURPOSE (check) == binfo)
cf22909c
KL
278 return;
279 /* If not, record the check. */
280 deferred_access_stack->deferred_access_checks
6df5158a 281 = tree_cons (binfo, decl,
cf22909c
KL
282 deferred_access_stack->deferred_access_checks);
283}
284
838dfd8a 285/* Returns nonzero if the current statement is a full expression,
f2c5f623
BC
286 i.e. temporaries created during that statement should be destroyed
287 at the end of the statement. */
35b1567d 288
f2c5f623 289int
3a978d72 290stmts_are_full_exprs_p (void)
f2c5f623 291{
ae499cce
MM
292 return current_stmt_tree ()->stmts_are_full_exprs_p;
293}
294
295/* Returns the stmt_tree (if any) to which statements are currently
296 being added. If there is no active statement-tree, NULL is
297 returned. */
298
299stmt_tree
3a978d72 300current_stmt_tree (void)
ae499cce
MM
301{
302 return (cfun
e2500fed 303 ? &cfun->language->base.x_stmt_tree
ae499cce 304 : &scope_chain->x_stmt_tree);
f2c5f623 305}
35b1567d 306
f2c5f623
BC
307/* Nonzero if TYPE is an anonymous union or struct type. We have to use a
308 flag for this because "A union for which objects or pointers are
309 declared is not an anonymous union" [class.union]. */
35b1567d 310
f2c5f623 311int
3a978d72 312anon_aggr_type_p (tree node)
35b1567d 313{
e2500fed 314 return ANON_AGGR_TYPE_P (node);
35b1567d
BC
315}
316
f2c5f623 317/* Finish a scope. */
35b1567d 318
325c3691
RH
319static tree
320do_poplevel (tree stmt_list)
35b1567d 321{
325c3691 322 tree block = NULL;
35b1567d 323
f2c5f623 324 if (stmts_are_full_exprs_p ())
325c3691 325 block = poplevel (kept_level_p (), 1, 0);
f2c5f623 326
325c3691
RH
327 stmt_list = pop_stmt_list (stmt_list);
328
329 if (!processing_template_decl)
330 {
331 stmt_list = c_build_bind_expr (block, stmt_list);
332 /* ??? See c_end_compound_stmt re statement expressions. */
35b1567d
BC
333 }
334
325c3691 335 return stmt_list;
35b1567d
BC
336}
337
f2c5f623 338/* Begin a new scope. */
35b1567d 339
325c3691 340static tree
92bc1323 341do_pushlevel (scope_kind sk)
35b1567d 342{
325c3691 343 tree ret = push_stmt_list ();
f2c5f623 344 if (stmts_are_full_exprs_p ())
325c3691
RH
345 begin_scope (sk, NULL);
346 return ret;
347}
348
349/* Finish processing a conditional. COND contains the raw expression;
350 STMT_P is a stacked statement list that will contain any other stmts
351 emitting during the processing of this conditional. Place the
352 resulting conditional back in STMT_P. */
353
354static void
355finish_cond (tree cond, tree *stmt_p)
356{
357 tree stmt = *stmt_p;
358 stmt = pop_stmt_list (stmt);
359 if (TREE_SIDE_EFFECTS (stmt))
35b1567d 360 {
325c3691
RH
361 /* If stmt is set, it will be a DECL_STMT. When processing a template,
362 using this is enough, because tsubst_expr considers the result of a
363 DECL_STMT to be the DECL. When generating real code, we build a
364 funny little TREE_LIST thingy that's handled by the gimplifier. */
365 /* ??? The object of this thingy is to get the DECL declared in the
366 proper scope. Seems like this oughtn't be terribly hard with the
367 new explicit uses of BIND_EXPR and such. */
368 if (processing_template_decl)
369 {
370 stmt = expr_only (stmt);
371 if (!stmt)
372 abort ();
373 }
374 else
375 stmt = build_tree_list (stmt, cond);
35b1567d 376 }
325c3691
RH
377 else
378 stmt = cond;
379 *stmt_p = stmt;
35b1567d
BC
380}
381
325c3691
RH
382/* If *COND_P specifies a conditional with a declaration, transform the
383 loop such that
384 while (A x = 42) { }
385 for (; A x = 42;) { }
386 becomes
387 while (true) { A x = 42; if (!x) break; }
388 for (;;) { A x = 42; if (!x) break; }
389 The statement list for the loop body should have been pushed. */
390
391static void
392simplify_loop_decl_cond (tree *cond_p)
393{
394 tree cond = *cond_p;
395 if (TREE_CODE (cond) == TREE_LIST)
396 {
397 tree if_stmt;
398
399 *cond_p = boolean_true_node;
400
401 if_stmt = begin_if_stmt ();
402 add_stmt (TREE_PURPOSE (cond));
403 cond = build_unary_op (TRUTH_NOT_EXPR, TREE_VALUE (cond), 0);
404 finish_if_stmt_cond (cond, if_stmt);
405 finish_break_stmt ();
406 finish_then_clause (if_stmt);
407 finish_if_stmt (if_stmt);
408 }
409}
410
411
35b1567d
BC
412/* Finish a goto-statement. */
413
3e4d04a1 414tree
3a978d72 415finish_goto_stmt (tree destination)
35b1567d
BC
416{
417 if (TREE_CODE (destination) == IDENTIFIER_NODE)
418 destination = lookup_label (destination);
419
420 /* We warn about unused labels with -Wunused. That means we have to
421 mark the used labels as used. */
422 if (TREE_CODE (destination) == LABEL_DECL)
423 TREE_USED (destination) = 1;
fc2b8477
MM
424 else
425 {
426 /* The DESTINATION is being used as an rvalue. */
427 if (!processing_template_decl)
428 destination = decay_conversion (destination);
429 /* We don't inline calls to functions with computed gotos.
430 Those functions are typically up to some funny business,
431 and may be depending on the labels being at particular
432 addresses, or some such. */
433 DECL_UNINLINABLE (current_function_decl) = 1;
434 }
35b1567d
BC
435
436 check_goto (destination);
437
9e14e18f 438 return add_stmt (build_stmt (GOTO_EXPR, destination));
35b1567d
BC
439}
440
ed5511d9
MM
441/* COND is the condition-expression for an if, while, etc.,
442 statement. Convert it to a boolean value, if appropriate. */
443
8ce33230 444static tree
3a978d72 445maybe_convert_cond (tree cond)
ed5511d9
MM
446{
447 /* Empty conditions remain empty. */
448 if (!cond)
449 return NULL_TREE;
450
451 /* Wait until we instantiate templates before doing conversion. */
452 if (processing_template_decl)
453 return cond;
454
455 /* Do the conversion. */
456 cond = convert_from_reference (cond);
457 return condition_conversion (cond);
458}
459
9bfadf57 460/* Finish an expression-statement, whose EXPRESSION is as indicated. */
a7e4cfa0 461
3e4d04a1 462tree
3a978d72 463finish_expr_stmt (tree expr)
ad321293 464{
3e4d04a1
RH
465 tree r = NULL_TREE;
466
ce4a0391 467 if (expr != NULL_TREE)
ad321293 468 {
a5bcc582 469 if (!processing_template_decl)
35b1567d 470 expr = convert_to_void (expr, "statement");
47d4c811
NS
471 else if (!type_dependent_expression_p (expr))
472 convert_to_void (build_non_dependent_expr (expr), "statement");
325c3691
RH
473
474 /* Simplification of inner statement expressions, compound exprs,
475 etc can result in the us already having an EXPR_STMT. */
476 if (TREE_CODE (expr) != EXPR_STMT)
477 expr = build_stmt (EXPR_STMT, expr);
478 r = add_stmt (expr);
35b1567d 479 }
364460b6 480
35b1567d 481 finish_stmt ();
558475f0 482
3e4d04a1 483 return r;
35b1567d
BC
484}
485
35b1567d 486
ad321293
MM
487/* Begin an if-statement. Returns a newly created IF_STMT if
488 appropriate. */
489
490tree
3a978d72 491begin_if_stmt (void)
ad321293 492{
325c3691
RH
493 tree r, scope;
494 scope = do_pushlevel (sk_block);
0dfdeca6 495 r = build_stmt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
325c3691 496 TREE_CHAIN (r) = scope;
ae499cce 497 add_stmt (r);
325c3691 498 IF_COND (r) = push_stmt_list ();
ad321293
MM
499 return r;
500}
501
502/* Process the COND of an if-statement, which may be given by
503 IF_STMT. */
504
505void
3a978d72 506finish_if_stmt_cond (tree cond, tree if_stmt)
ad321293 507{
ed5511d9 508 cond = maybe_convert_cond (cond);
325c3691
RH
509 finish_cond (cond, &IF_COND (if_stmt));
510 THEN_CLAUSE (if_stmt) = push_stmt_list ();
ad321293
MM
511}
512
513/* Finish the then-clause of an if-statement, which may be given by
514 IF_STMT. */
515
516tree
3a978d72 517finish_then_clause (tree if_stmt)
ad321293 518{
325c3691 519 THEN_CLAUSE (if_stmt) = pop_stmt_list (THEN_CLAUSE (if_stmt));
35b1567d 520 return if_stmt;
ad321293
MM
521}
522
523/* Begin the else-clause of an if-statement. */
524
325c3691
RH
525void
526begin_else_clause (tree if_stmt)
ad321293 527{
325c3691 528 ELSE_CLAUSE (if_stmt) = push_stmt_list ();
ad321293
MM
529}
530
531/* Finish the else-clause of an if-statement, which may be given by
532 IF_STMT. */
533
534void
3a978d72 535finish_else_clause (tree if_stmt)
ad321293 536{
325c3691 537 ELSE_CLAUSE (if_stmt) = pop_stmt_list (ELSE_CLAUSE (if_stmt));
ad321293
MM
538}
539
dfbb4f34 540/* Finish an if-statement. */
ad321293
MM
541
542void
325c3691 543finish_if_stmt (tree if_stmt)
ad321293 544{
325c3691
RH
545 tree scope = TREE_CHAIN (if_stmt);
546 TREE_CHAIN (if_stmt) = NULL;
547 add_stmt (do_poplevel (scope));
ad321293 548 finish_stmt ();
35b1567d
BC
549}
550
ad321293
MM
551/* Begin a while-statement. Returns a newly created WHILE_STMT if
552 appropriate. */
553
554tree
3a978d72 555begin_while_stmt (void)
ad321293
MM
556{
557 tree r;
0dfdeca6 558 r = build_stmt (WHILE_STMT, NULL_TREE, NULL_TREE);
ae499cce 559 add_stmt (r);
325c3691
RH
560 WHILE_BODY (r) = do_pushlevel (sk_block);
561 WHILE_COND (r) = push_stmt_list ();
ad321293
MM
562 return r;
563}
564
27d26ee7 565/* Process the COND of a while-statement, which may be given by
ad321293
MM
566 WHILE_STMT. */
567
568void
3a978d72 569finish_while_stmt_cond (tree cond, tree while_stmt)
ad321293 570{
ed5511d9 571 cond = maybe_convert_cond (cond);
325c3691
RH
572 finish_cond (cond, &WHILE_COND (while_stmt));
573 simplify_loop_decl_cond (&WHILE_COND (while_stmt));
ad321293
MM
574}
575
576/* Finish a while-statement, which may be given by WHILE_STMT. */
577
578void
3a978d72 579finish_while_stmt (tree while_stmt)
ad321293 580{
325c3691 581 WHILE_BODY (while_stmt) = do_poplevel (WHILE_BODY (while_stmt));
ad321293
MM
582 finish_stmt ();
583}
584
585/* Begin a do-statement. Returns a newly created DO_STMT if
586 appropriate. */
587
588tree
3a978d72 589begin_do_stmt (void)
ad321293 590{
0dfdeca6 591 tree r = build_stmt (DO_STMT, NULL_TREE, NULL_TREE);
ae499cce 592 add_stmt (r);
325c3691 593 DO_BODY (r) = push_stmt_list ();
35b1567d 594 return r;
ad321293
MM
595}
596
597/* Finish the body of a do-statement, which may be given by DO_STMT. */
598
599void
3a978d72 600finish_do_body (tree do_stmt)
ad321293 601{
325c3691 602 DO_BODY (do_stmt) = pop_stmt_list (DO_BODY (do_stmt));
ad321293
MM
603}
604
605/* Finish a do-statement, which may be given by DO_STMT, and whose
606 COND is as indicated. */
607
608void
3a978d72 609finish_do_stmt (tree cond, tree do_stmt)
ad321293 610{
ed5511d9 611 cond = maybe_convert_cond (cond);
35b1567d
BC
612 DO_COND (do_stmt) = cond;
613 finish_stmt ();
614}
ed5511d9 615
ad321293
MM
616/* Finish a return-statement. The EXPRESSION returned, if any, is as
617 indicated. */
618
3e4d04a1 619tree
3a978d72 620finish_return_stmt (tree expr)
ad321293 621{
3e4d04a1
RH
622 tree r;
623
efc7052d 624 expr = check_return_expr (expr);
35b1567d 625 if (!processing_template_decl)
efee38a9 626 {
a0de9d20 627 if (DECL_DESTRUCTOR_P (current_function_decl))
efee38a9
MM
628 {
629 /* Similarly, all destructors must run destructors for
630 base-classes before returning. So, all returns in a
dfbb4f34 631 destructor get sent to the DTOR_LABEL; finish_function emits
efee38a9 632 code to return a value there. */
3e4d04a1 633 return finish_goto_stmt (dtor_label);
efee38a9
MM
634 }
635 }
3e4d04a1 636 r = add_stmt (build_stmt (RETURN_STMT, expr));
35b1567d 637 finish_stmt ();
3e4d04a1
RH
638
639 return r;
35b1567d 640}
efee38a9 641
ad321293
MM
642/* Begin a for-statement. Returns a new FOR_STMT if appropriate. */
643
644tree
3a978d72 645begin_for_stmt (void)
ad321293
MM
646{
647 tree r;
648
0dfdeca6
BC
649 r = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
650 NULL_TREE, NULL_TREE);
325c3691
RH
651
652 if (flag_new_for_scope > 0)
653 TREE_CHAIN (r) = do_pushlevel (sk_for);
ad321293 654
894ca2c9
RH
655 if (processing_template_decl)
656 FOR_INIT_STMT (r) = push_stmt_list ();
657
ad321293
MM
658 return r;
659}
660
661/* Finish the for-init-statement of a for-statement, which may be
662 given by FOR_STMT. */
663
664void
3a978d72 665finish_for_init_stmt (tree for_stmt)
ad321293 666{
894ca2c9
RH
667 if (processing_template_decl)
668 FOR_INIT_STMT (for_stmt) = pop_stmt_list (FOR_INIT_STMT (for_stmt));
325c3691
RH
669 add_stmt (for_stmt);
670 FOR_BODY (for_stmt) = do_pushlevel (sk_block);
671 FOR_COND (for_stmt) = push_stmt_list ();
ad321293
MM
672}
673
674/* Finish the COND of a for-statement, which may be given by
675 FOR_STMT. */
676
677void
3a978d72 678finish_for_cond (tree cond, tree for_stmt)
ad321293 679{
ed5511d9 680 cond = maybe_convert_cond (cond);
325c3691
RH
681 finish_cond (cond, &FOR_COND (for_stmt));
682 if (FOR_COND (for_stmt))
683 simplify_loop_decl_cond (&FOR_COND (for_stmt));
ad321293
MM
684}
685
686/* Finish the increment-EXPRESSION in a for-statement, which may be
687 given by FOR_STMT. */
688
689void
3a978d72 690finish_for_expr (tree expr, tree for_stmt)
ad321293 691{
6f69173e
MM
692 /* If EXPR is an overloaded function, issue an error; there is no
693 context available to use to perform overload resolution. */
694 if (expr && type_unknown_p (expr))
695 {
696 cxx_incomplete_type_error (expr, TREE_TYPE (expr));
697 expr = error_mark_node;
698 }
35b1567d 699 FOR_EXPR (for_stmt) = expr;
ad321293
MM
700}
701
702/* Finish the body of a for-statement, which may be given by
703 FOR_STMT. The increment-EXPR for the loop must be
704 provided. */
705
706void
3a978d72 707finish_for_stmt (tree for_stmt)
ad321293 708{
325c3691
RH
709 FOR_BODY (for_stmt) = do_poplevel (FOR_BODY (for_stmt));
710
ad321293 711 /* Pop the scope for the body of the loop. */
325c3691
RH
712 if (flag_new_for_scope > 0)
713 {
714 tree scope = TREE_CHAIN (for_stmt);
715 TREE_CHAIN (for_stmt) = NULL;
716 add_stmt (do_poplevel (scope));
717 }
718
ad321293
MM
719 finish_stmt ();
720}
721
722/* Finish a break-statement. */
723
3e4d04a1 724tree
3a978d72 725finish_break_stmt (void)
ad321293 726{
3e4d04a1 727 return add_stmt (build_break_stmt ());
35b1567d
BC
728}
729
ad321293
MM
730/* Finish a continue-statement. */
731
3e4d04a1 732tree
3a978d72 733finish_continue_stmt (void)
ad321293 734{
3e4d04a1 735 return add_stmt (build_continue_stmt ());
ad321293
MM
736}
737
35b1567d
BC
738/* Begin a switch-statement. Returns a new SWITCH_STMT if
739 appropriate. */
740
741tree
3a978d72 742begin_switch_stmt (void)
35b1567d 743{
325c3691
RH
744 tree r, scope;
745
6f9fdf4d 746 r = build_stmt (SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
325c3691
RH
747
748 scope = do_pushlevel (sk_block);
749 TREE_CHAIN (r) = scope;
750
ae499cce 751 add_stmt (r);
325c3691
RH
752 SWITCH_COND (r) = push_stmt_list ();
753
527f0080 754 return r;
ad321293
MM
755}
756
527f0080 757/* Finish the cond of a switch-statement. */
ad321293 758
527f0080 759void
3a978d72 760finish_switch_cond (tree cond, tree switch_stmt)
ad321293 761{
6f9fdf4d 762 tree orig_type = NULL;
35b1567d 763 if (!processing_template_decl)
373eb3b3 764 {
56cb9733
MM
765 tree index;
766
35b1567d 767 /* Convert the condition to an integer or enumeration type. */
b746c5dc 768 cond = build_expr_type_conversion (WANT_INT | WANT_ENUM, cond, true);
35b1567d 769 if (cond == NULL_TREE)
373eb3b3 770 {
35b1567d
BC
771 error ("switch quantity not an integer");
772 cond = error_mark_node;
773 }
6f9fdf4d 774 orig_type = TREE_TYPE (cond);
35b1567d
BC
775 if (cond != error_mark_node)
776 {
0a72704b
MM
777 /* [stmt.switch]
778
779 Integral promotions are performed. */
780 cond = perform_integral_promotions (cond);
2bb5d995 781 cond = fold (build1 (CLEANUP_POINT_EXPR, TREE_TYPE (cond), cond));
373eb3b3 782 }
56cb9733 783
25c8b645
JJ
784 if (cond != error_mark_node)
785 {
786 index = get_unwidened (cond, NULL_TREE);
787 /* We can't strip a conversion from a signed type to an unsigned,
788 because if we did, int_fits_type_p would do the wrong thing
789 when checking case values for being in range,
790 and it's too hard to do the right thing. */
8df83eae
RK
791 if (TYPE_UNSIGNED (TREE_TYPE (cond))
792 == TYPE_UNSIGNED (TREE_TYPE (index)))
25c8b645
JJ
793 cond = index;
794 }
ad321293 795 }
325c3691 796 finish_cond (cond, &SWITCH_COND (switch_stmt));
6f9fdf4d 797 SWITCH_TYPE (switch_stmt) = orig_type;
56cb9733 798 push_switch (switch_stmt);
325c3691 799 SWITCH_BODY (switch_stmt) = push_stmt_list ();
ad321293
MM
800}
801
802/* Finish the body of a switch-statement, which may be given by
803 SWITCH_STMT. The COND to switch on is indicated. */
804
805void
3a978d72 806finish_switch_stmt (tree switch_stmt)
ad321293 807{
325c3691
RH
808 tree scope;
809
810 SWITCH_BODY (switch_stmt) = pop_stmt_list (SWITCH_BODY (switch_stmt));
ad321293 811 pop_switch ();
ad321293 812 finish_stmt ();
325c3691
RH
813
814 scope = TREE_CHAIN (switch_stmt);
815 TREE_CHAIN (switch_stmt) = NULL;
816 add_stmt (do_poplevel (scope));
ad321293
MM
817}
818
ad321293
MM
819/* Begin a try-block. Returns a newly-created TRY_BLOCK if
820 appropriate. */
821
822tree
3a978d72 823begin_try_block (void)
ad321293 824{
0dfdeca6 825 tree r = build_stmt (TRY_BLOCK, NULL_TREE, NULL_TREE);
ae499cce 826 add_stmt (r);
325c3691 827 TRY_STMTS (r) = push_stmt_list ();
35b1567d 828 return r;
ad321293
MM
829}
830
0dde4175
JM
831/* Likewise, for a function-try-block. */
832
833tree
3a978d72 834begin_function_try_block (void)
0dde4175 835{
325c3691 836 tree r = begin_try_block ();
35b1567d 837 FN_TRY_BLOCK_P (r) = 1;
35b1567d 838 return r;
0dde4175
JM
839}
840
ad321293
MM
841/* Finish a try-block, which may be given by TRY_BLOCK. */
842
843void
3a978d72 844finish_try_block (tree try_block)
ad321293 845{
325c3691
RH
846 TRY_STMTS (try_block) = pop_stmt_list (TRY_STMTS (try_block));
847 TRY_HANDLERS (try_block) = push_stmt_list ();
ad321293
MM
848}
849
efa8eda3
MM
850/* Finish the body of a cleanup try-block, which may be given by
851 TRY_BLOCK. */
852
62409b39 853void
3a978d72 854finish_cleanup_try_block (tree try_block)
62409b39 855{
325c3691 856 TRY_STMTS (try_block) = pop_stmt_list (TRY_STMTS (try_block));
62409b39
MM
857}
858
f1dedc31
MM
859/* Finish an implicitly generated try-block, with a cleanup is given
860 by CLEANUP. */
861
862void
3a978d72 863finish_cleanup (tree cleanup, tree try_block)
f1dedc31 864{
35b1567d
BC
865 TRY_HANDLERS (try_block) = cleanup;
866 CLEANUP_P (try_block) = 1;
f1dedc31
MM
867}
868
0dde4175
JM
869/* Likewise, for a function-try-block. */
870
871void
3a978d72 872finish_function_try_block (tree try_block)
0dde4175 873{
325c3691
RH
874 finish_try_block (try_block);
875 /* FIXME : something queer about CTOR_INITIALIZER somehow following
876 the try block, but moving it inside. */
b35d4555 877 in_function_try_handler = 1;
0dde4175
JM
878}
879
ad321293
MM
880/* Finish a handler-sequence for a try-block, which may be given by
881 TRY_BLOCK. */
882
883void
3a978d72 884finish_handler_sequence (tree try_block)
ad321293 885{
325c3691 886 TRY_HANDLERS (try_block) = pop_stmt_list (TRY_HANDLERS (try_block));
35b1567d 887 check_handlers (TRY_HANDLERS (try_block));
ad321293
MM
888}
889
0dde4175
JM
890/* Likewise, for a function-try-block. */
891
892void
3a978d72 893finish_function_handler_sequence (tree try_block)
0dde4175 894{
b35d4555 895 in_function_try_handler = 0;
325c3691 896 finish_handler_sequence (try_block);
35b1567d
BC
897}
898
ad321293
MM
899/* Begin a handler. Returns a HANDLER if appropriate. */
900
901tree
3a978d72 902begin_handler (void)
ad321293
MM
903{
904 tree r;
325c3691 905
0dfdeca6 906 r = build_stmt (HANDLER, NULL_TREE, NULL_TREE);
ae499cce 907 add_stmt (r);
325c3691 908
1a6025b4
JM
909 /* Create a binding level for the eh_info and the exception object
910 cleanup. */
325c3691
RH
911 HANDLER_BODY (r) = do_pushlevel (sk_catch);
912
ad321293
MM
913 return r;
914}
915
916/* Finish the handler-parameters for a handler, which may be given by
b35d4555
MM
917 HANDLER. DECL is the declaration for the catch parameter, or NULL
918 if this is a `catch (...)' clause. */
ad321293 919
1a6025b4 920void
3a978d72 921finish_handler_parms (tree decl, tree handler)
b35d4555 922{
1a6025b4 923 tree type = NULL_TREE;
b35d4555
MM
924 if (processing_template_decl)
925 {
926 if (decl)
927 {
928 decl = pushdecl (decl);
929 decl = push_template_decl (decl);
325c3691 930 HANDLER_PARMS (handler) = decl;
1a6025b4 931 type = TREE_TYPE (decl);
b35d4555
MM
932 }
933 }
35b1567d 934 else
1a6025b4 935 type = expand_start_catch_block (decl);
35b1567d 936
1a6025b4 937 HANDLER_TYPE (handler) = type;
b80cfdcd 938 if (!processing_template_decl && type)
6cad4e17 939 mark_used (eh_type_info (type));
35b1567d
BC
940}
941
942/* Finish a handler, which may be given by HANDLER. The BLOCKs are
943 the return value from the matching call to finish_handler_parms. */
944
945void
3a978d72 946finish_handler (tree handler)
35b1567d
BC
947{
948 if (!processing_template_decl)
1a6025b4 949 expand_end_catch_block ();
325c3691 950 HANDLER_BODY (handler) = do_poplevel (HANDLER_BODY (handler));
35b1567d
BC
951}
952
7a3397c7 953/* Begin a compound-statement. If HAS_NO_SCOPE is true, the
ad321293 954 compound-statement does not define a scope. Returns a new
7a3397c7 955 COMPOUND_STMT. */
ad321293
MM
956
957tree
325c3691 958begin_compound_stmt (unsigned int flags)
ad321293 959{
325c3691 960 tree r;
558475f0 961
325c3691
RH
962 if (flags & BCS_NO_SCOPE)
963 {
964 r = push_stmt_list ();
965 STATEMENT_LIST_NO_SCOPE (r) = 1;
966
967 /* Normally, we try hard to keep the BLOCK for a statement-expression.
968 But, if it's a statement-expression with a scopeless block, there's
969 nothing to keep, and we don't want to accidentally keep a block
970 *inside* the scopeless block. */
971 keep_next_level (false);
972 }
f1dedc31 973 else
325c3691
RH
974 r = do_pushlevel (flags & BCS_TRY_BLOCK ? sk_try : sk_block);
975
976 if (flags & BCS_FN_BODY || processing_template_decl)
977 {
978 r = build (COMPOUND_STMT, NULL_TREE, r);
979 COMPOUND_STMT_TRY_BLOCK (r) = (flags & BCS_TRY_BLOCK) != 0;
980 COMPOUND_STMT_BODY_BLOCK (r) = (flags & BCS_FN_BODY) != 0;
981 TREE_SIDE_EFFECTS (r) = 1;
982 }
ad321293
MM
983
984 return r;
985}
986
04c06002 987/* Finish a compound-statement, which is given by COMPOUND_STMT. */
ad321293 988
325c3691
RH
989void
990finish_compound_stmt (tree stmt)
ad321293 991{
325c3691
RH
992 if (TREE_CODE (stmt) == COMPOUND_STMT)
993 COMPOUND_BODY (stmt) = do_poplevel (COMPOUND_BODY (stmt));
994 else if (STATEMENT_LIST_NO_SCOPE (stmt))
995 stmt = pop_stmt_list (stmt);
7a3397c7 996 else
325c3691 997 stmt = do_poplevel (stmt);
ad321293 998
325c3691
RH
999 /* ??? See c_end_compound_stmt wrt statement expressions. */
1000 add_stmt (stmt);
ad321293 1001 finish_stmt ();
ad321293
MM
1002}
1003
6de9cd9a
DN
1004/* Finish an asm-statement, whose components are a STRING, some
1005 OUTPUT_OPERANDS, some INPUT_OPERANDS, and some CLOBBERS. Also note
1006 whether the asm-statement should be considered volatile. */
7dc5bd62 1007
3e4d04a1 1008tree
6de9cd9a
DN
1009finish_asm_stmt (int volatile_p, tree string, tree output_operands,
1010 tree input_operands, tree clobbers)
35b1567d
BC
1011{
1012 tree r;
abfc8a36
MM
1013 tree t;
1014
abfc8a36 1015 if (!processing_template_decl)
40b18c0a
MM
1016 {
1017 int i;
1018 int ninputs;
1019 int noutputs;
1020
1021 for (t = input_operands; t; t = TREE_CHAIN (t))
1022 {
1023 tree converted_operand
1024 = decay_conversion (TREE_VALUE (t));
1025
1026 /* If the type of the operand hasn't been determined (e.g.,
1027 because it involves an overloaded function), then issue
1028 an error message. There's no context available to
1029 resolve the overloading. */
1030 if (TREE_TYPE (converted_operand) == unknown_type_node)
1031 {
33bd39a2 1032 error ("type of asm operand `%E' could not be determined",
40b18c0a
MM
1033 TREE_VALUE (t));
1034 converted_operand = error_mark_node;
1035 }
1036 TREE_VALUE (t) = converted_operand;
1037 }
1038
1039 ninputs = list_length (input_operands);
1040 noutputs = list_length (output_operands);
1041
1042 for (i = 0, t = output_operands; t; t = TREE_CHAIN (t), ++i)
1043 {
1044 bool allows_mem;
1045 bool allows_reg;
1046 bool is_inout;
1047 const char *constraint;
1048 tree operand;
1049
84b72302 1050 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
28c56d25 1051 operand = TREE_VALUE (t);
40b18c0a
MM
1052
1053 if (!parse_output_constraint (&constraint,
1054 i, ninputs, noutputs,
1055 &allows_mem,
1056 &allows_reg,
1057 &is_inout))
1058 {
a723baf1
MM
1059 /* By marking this operand as erroneous, we will not try
1060 to process this operand again in expand_asm_operands. */
1061 TREE_VALUE (t) = error_mark_node;
40b18c0a
MM
1062 continue;
1063 }
1064
1065 /* If the operand is a DECL that is going to end up in
1066 memory, assume it is addressable. This is a bit more
1067 conservative than it would ideally be; the exact test is
1068 buried deep in expand_asm_operands and depends on the
1069 DECL_RTL for the OPERAND -- which we don't have at this
1070 point. */
1071 if (!allows_reg && DECL_P (operand))
dffd7eb6 1072 cxx_mark_addressable (operand);
40b18c0a
MM
1073 }
1074 }
abfc8a36 1075
6de9cd9a 1076 r = build_stmt (ASM_STMT, string,
0dfdeca6
BC
1077 output_operands, input_operands,
1078 clobbers);
6de9cd9a 1079 ASM_VOLATILE_P (r) = volatile_p;
3e4d04a1 1080 return add_stmt (r);
ad321293 1081}
b4c4a9ec 1082
f01b0acb
MM
1083/* Finish a label with the indicated NAME. */
1084
a723baf1 1085tree
3a978d72 1086finish_label_stmt (tree name)
f01b0acb 1087{
5b030314 1088 tree decl = define_label (input_location, name);
9e14e18f 1089 return add_stmt (build_stmt (LABEL_EXPR, decl));
f01b0acb
MM
1090}
1091
acef433b
MM
1092/* Finish a series of declarations for local labels. G++ allows users
1093 to declare "local" labels, i.e., labels with scope. This extension
1094 is useful when writing code involving statement-expressions. */
1095
1096void
3a978d72 1097finish_label_decl (tree name)
acef433b
MM
1098{
1099 tree decl = declare_local_label (name);
35b1567d 1100 add_decl_stmt (decl);
acef433b
MM
1101}
1102
659e5a7a 1103/* When DECL goes out of scope, make sure that CLEANUP is executed. */
f1dedc31
MM
1104
1105void
3a978d72 1106finish_decl_cleanup (tree decl, tree cleanup)
f1dedc31 1107{
325c3691 1108 push_cleanup (decl, cleanup, false);
35b1567d
BC
1109}
1110
659e5a7a 1111/* If the current scope exits with an exception, run CLEANUP. */
24bef158 1112
659e5a7a 1113void
3a978d72 1114finish_eh_cleanup (tree cleanup)
24bef158 1115{
325c3691 1116 push_cleanup (NULL, cleanup, true);
35b1567d
BC
1117}
1118
2282d28d
MM
1119/* The MEM_INITS is a list of mem-initializers, in reverse of the
1120 order they were written by the user. Each node is as for
1121 emit_mem_initializers. */
bf3428d0
MM
1122
1123void
2282d28d 1124finish_mem_initializers (tree mem_inits)
bf3428d0 1125{
2282d28d
MM
1126 /* Reorder the MEM_INITS so that they are in the order they appeared
1127 in the source program. */
1128 mem_inits = nreverse (mem_inits);
bf3428d0 1129
a0de9d20 1130 if (processing_template_decl)
2282d28d 1131 add_stmt (build_min_nt (CTOR_INITIALIZER, mem_inits));
cdd2559c 1132 else
2282d28d 1133 emit_mem_initializers (mem_inits);
558475f0
MM
1134}
1135
b4c4a9ec
MM
1136/* Finish a parenthesized expression EXPR. */
1137
1138tree
3a978d72 1139finish_parenthesized_expr (tree expr)
b4c4a9ec
MM
1140{
1141 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
78ef5b89 1142 /* This inhibits warnings in c_common_truthvalue_conversion. */
b4c4a9ec
MM
1143 C_SET_EXP_ORIGINAL_CODE (expr, ERROR_MARK);
1144
19420d00
NS
1145 if (TREE_CODE (expr) == OFFSET_REF)
1146 /* [expr.unary.op]/3 The qualified id of a pointer-to-member must not be
1147 enclosed in parentheses. */
1148 PTRMEM_OK_P (expr) = 0;
b4c4a9ec
MM
1149 return expr;
1150}
1151
a723baf1
MM
1152/* Finish a reference to a non-static data member (DECL) that is not
1153 preceded by `.' or `->'. */
1154
1155tree
a3f10e50 1156finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
a723baf1
MM
1157{
1158 my_friendly_assert (TREE_CODE (decl) == FIELD_DECL, 20020909);
1159
a3f10e50 1160 if (!object)
a723baf1
MM
1161 {
1162 if (current_function_decl
1163 && DECL_STATIC_FUNCTION_P (current_function_decl))
1164 cp_error_at ("invalid use of member `%D' in static member function",
1165 decl);
1166 else
1167 cp_error_at ("invalid use of non-static data member `%D'", decl);
1168 error ("from this location");
1169
1170 return error_mark_node;
1171 }
1172 TREE_USED (current_class_ptr) = 1;
58e1d54c 1173 if (processing_template_decl && !qualifying_scope)
a723baf1 1174 {
a3f10e50 1175 tree type = TREE_TYPE (decl);
a723baf1 1176
a3f10e50
NS
1177 if (TREE_CODE (type) == REFERENCE_TYPE)
1178 type = TREE_TYPE (type);
1179 else
1180 {
f4f206f4 1181 /* Set the cv qualifiers. */
a3f10e50
NS
1182 int quals = cp_type_quals (TREE_TYPE (current_class_ref));
1183
1184 if (DECL_MUTABLE_P (decl))
1185 quals &= ~TYPE_QUAL_CONST;
9e95d15f 1186
a3f10e50
NS
1187 quals |= cp_type_quals (TREE_TYPE (decl));
1188 type = cp_build_qualified_type (type, quals);
1189 }
9e95d15f 1190
a3f10e50
NS
1191 return build_min (COMPONENT_REF, type, object, decl);
1192 }
1193 else
1194 {
1195 tree access_type = TREE_TYPE (object);
1196 tree lookup_context = context_for_name_lookup (decl);
1197
1198 while (!DERIVED_FROM_P (lookup_context, access_type))
a723baf1
MM
1199 {
1200 access_type = TYPE_CONTEXT (access_type);
9f01ded6 1201 while (access_type && DECL_P (access_type))
a723baf1 1202 access_type = DECL_CONTEXT (access_type);
a723baf1 1203
a3f10e50
NS
1204 if (!access_type)
1205 {
1206 cp_error_at ("object missing in reference to `%D'", decl);
1207 error ("from this location");
1208 return error_mark_node;
1209 }
9f01ded6
KL
1210 }
1211
5c425df5 1212 /* If PROCESSING_TEMPLATE_DECL is nonzero here, then
58e1d54c
KL
1213 QUALIFYING_SCOPE is also non-null. Wrap this in a SCOPE_REF
1214 for now. */
1215 if (processing_template_decl)
1216 return build_min (SCOPE_REF, TREE_TYPE (decl),
1217 qualifying_scope, DECL_NAME (decl));
1218
6df5158a 1219 perform_or_defer_access_check (TYPE_BINFO (access_type), decl);
a723baf1
MM
1220
1221 /* If the data member was named `C::M', convert `*this' to `C'
1222 first. */
1223 if (qualifying_scope)
1224 {
1225 tree binfo = NULL_TREE;
1226 object = build_scoped_ref (object, qualifying_scope,
1227 &binfo);
1228 }
1229
1230 return build_class_member_access_expr (object, decl,
1231 /*access_path=*/NULL_TREE,
1232 /*preserve_reference=*/false);
1233 }
1234}
1235
ee76b931
MM
1236/* DECL was the declaration to which a qualified-id resolved. Issue
1237 an error message if it is not accessible. If OBJECT_TYPE is
1238 non-NULL, we have just seen `x->' or `x.' and OBJECT_TYPE is the
1239 type of `*x', or `x', respectively. If the DECL was named as
1240 `A::B' then NESTED_NAME_SPECIFIER is `A'. */
1241
1242void
1243check_accessibility_of_qualified_id (tree decl,
1244 tree object_type,
1245 tree nested_name_specifier)
1246{
1247 tree scope;
1248 tree qualifying_type = NULL_TREE;
1249
1250 /* Determine the SCOPE of DECL. */
1251 scope = context_for_name_lookup (decl);
1252 /* If the SCOPE is not a type, then DECL is not a member. */
1253 if (!TYPE_P (scope))
1254 return;
1255 /* Compute the scope through which DECL is being accessed. */
1256 if (object_type
1257 /* OBJECT_TYPE might not be a class type; consider:
1258
1259 class A { typedef int I; };
1260 I *p;
1261 p->A::I::~I();
1262
1263 In this case, we will have "A::I" as the DECL, but "I" as the
1264 OBJECT_TYPE. */
1265 && CLASS_TYPE_P (object_type)
1266 && DERIVED_FROM_P (scope, object_type))
1267 /* If we are processing a `->' or `.' expression, use the type of the
1268 left-hand side. */
1269 qualifying_type = object_type;
1270 else if (nested_name_specifier)
1271 {
1272 /* If the reference is to a non-static member of the
1273 current class, treat it as if it were referenced through
1274 `this'. */
1275 if (DECL_NONSTATIC_MEMBER_P (decl)
1276 && current_class_ptr
1277 && DERIVED_FROM_P (scope, current_class_type))
1278 qualifying_type = current_class_type;
1279 /* Otherwise, use the type indicated by the
1280 nested-name-specifier. */
1281 else
1282 qualifying_type = nested_name_specifier;
1283 }
1284 else
1285 /* Otherwise, the name must be from the current class or one of
1286 its bases. */
1287 qualifying_type = currently_open_derived_class (scope);
1288
1289 if (qualifying_type)
1290 perform_or_defer_access_check (TYPE_BINFO (qualifying_type), decl);
1291}
1292
1293/* EXPR is the result of a qualified-id. The QUALIFYING_CLASS was the
1294 class named to the left of the "::" operator. DONE is true if this
1295 expression is a complete postfix-expression; it is false if this
1296 expression is followed by '->', '[', '(', etc. ADDRESS_P is true
1297 iff this expression is the operand of '&'. */
1298
1299tree
1300finish_qualified_id_expr (tree qualifying_class, tree expr, bool done,
1301 bool address_p)
1302{
5e08432e
MM
1303 if (error_operand_p (expr))
1304 return error_mark_node;
1305
ee76b931
MM
1306 /* If EXPR occurs as the operand of '&', use special handling that
1307 permits a pointer-to-member. */
1308 if (address_p && done)
1309 {
1310 if (TREE_CODE (expr) == SCOPE_REF)
1311 expr = TREE_OPERAND (expr, 1);
a5ac359a
MM
1312 expr = build_offset_ref (qualifying_class, expr,
1313 /*address_p=*/true);
ee76b931
MM
1314 return expr;
1315 }
1316
1317 if (TREE_CODE (expr) == FIELD_DECL)
a3f10e50
NS
1318 expr = finish_non_static_data_member (expr, current_class_ref,
1319 qualifying_class);
ee76b931
MM
1320 else if (BASELINK_P (expr) && !processing_template_decl)
1321 {
1322 tree fn;
1323 tree fns;
1324
1325 /* See if any of the functions are non-static members. */
1326 fns = BASELINK_FUNCTIONS (expr);
1327 if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
1328 fns = TREE_OPERAND (fns, 0);
1329 for (fn = fns; fn; fn = OVL_NEXT (fn))
1330 if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn))
1331 break;
1332 /* If so, the expression may be relative to the current
1333 class. */
1334 if (fn && current_class_type
1335 && DERIVED_FROM_P (qualifying_class, current_class_type))
1336 expr = (build_class_member_access_expr
1337 (maybe_dummy_object (qualifying_class, NULL),
1338 expr,
1339 BASELINK_ACCESS_BINFO (expr),
1340 /*preserve_reference=*/false));
1341 else if (done)
a5ac359a
MM
1342 /* The expression is a qualified name whose address is not
1343 being taken. */
1344 expr = build_offset_ref (qualifying_class, expr, /*address_p=*/false);
ee76b931
MM
1345 }
1346
1347 return expr;
1348}
1349
b69b1501
MM
1350/* Begin a statement-expression. The value returned must be passed to
1351 finish_stmt_expr. */
b4c4a9ec
MM
1352
1353tree
3a978d72 1354begin_stmt_expr (void)
b4c4a9ec 1355{
325c3691 1356 return push_stmt_list ();
35b1567d
BC
1357}
1358
a5bcc582
NS
1359/* Process the final expression of a statement expression. EXPR can be
1360 NULL, if the final expression is empty. Build up a TARGET_EXPR so
1361 that the result value can be safely returned to the enclosing
1362 expression. */
1363
1364tree
325c3691 1365finish_stmt_expr_expr (tree expr, tree stmt_expr)
a5bcc582
NS
1366{
1367 tree result = NULL_TREE;
1368 tree type = void_type_node;
1369
1370 if (expr)
1371 {
1372 type = TREE_TYPE (expr);
1373
1374 if (!processing_template_decl && !VOID_TYPE_P (TREE_TYPE (expr)))
1375 {
1376 if (TREE_CODE (type) == ARRAY_TYPE
1377 || TREE_CODE (type) == FUNCTION_TYPE)
1378 expr = decay_conversion (expr);
1379
1380 expr = convert_from_reference (expr);
1381 expr = require_complete_type (expr);
1382
1383 /* Build a TARGET_EXPR for this aggregate. finish_stmt_expr
1384 will then pull it apart so the lifetime of the target is
cd0be382 1385 within the scope of the expression containing this statement
a5bcc582
NS
1386 expression. */
1387 if (TREE_CODE (expr) == TARGET_EXPR)
1388 ;
1389 else if (!IS_AGGR_TYPE (type) || TYPE_HAS_TRIVIAL_INIT_REF (type))
1390 expr = build_target_expr_with_type (expr, type);
1391 else
1392 {
1393 /* Copy construct. */
1394 expr = build_special_member_call
1395 (NULL_TREE, complete_ctor_identifier,
1396 build_tree_list (NULL_TREE, expr),
1397 TYPE_BINFO (type), LOOKUP_NORMAL);
1398 expr = build_cplus_new (type, expr);
1399 my_friendly_assert (TREE_CODE (expr) == TARGET_EXPR, 20030729);
1400 }
1401 }
1402
1403 if (expr != error_mark_node)
1404 {
1405 result = build_stmt (EXPR_STMT, expr);
325c3691 1406 EXPR_STMT_STMT_EXPR_RESULT (result) = 1;
a5bcc582
NS
1407 add_stmt (result);
1408 }
1409 }
1410
1411 finish_stmt ();
1412
325c3691
RH
1413 /* Remember the last expression so that finish_stmt_expr
1414 can pull it apart. */
1415 TREE_TYPE (stmt_expr) = result;
a5bcc582
NS
1416
1417 return result;
1418}
1419
303b7406
NS
1420/* Finish a statement-expression. EXPR should be the value returned
1421 by the previous begin_stmt_expr. Returns an expression
1422 representing the statement-expression. */
b4c4a9ec
MM
1423
1424tree
325c3691 1425finish_stmt_expr (tree stmt_expr, bool has_no_scope)
b4c4a9ec 1426{
325c3691
RH
1427 tree result, result_stmt, type;
1428 tree *result_stmt_p = NULL;
1429
1430 result_stmt = TREE_TYPE (stmt_expr);
1431 TREE_TYPE (stmt_expr) = void_type_node;
1432 result = pop_stmt_list (stmt_expr);
1433
1434 if (!result_stmt || VOID_TYPE_P (result_stmt))
a5bcc582
NS
1435 type = void_type_node;
1436 else
1437 {
325c3691
RH
1438 /* We need to search the statement expression for the result_stmt,
1439 since we'll need to replace it entirely. */
1440 tree t;
1441 result_stmt_p = &result;
1442 while (1)
a5bcc582 1443 {
325c3691
RH
1444 t = *result_stmt_p;
1445 if (t == result_stmt)
1446 break;
1447
1448 switch (TREE_CODE (t))
1449 {
1450 case STATEMENT_LIST:
1451 {
1452 tree_stmt_iterator i = tsi_last (t);
1453 result_stmt_p = tsi_stmt_ptr (i);
1454 break;
1455 }
1456 case BIND_EXPR:
1457 result_stmt_p = &BIND_EXPR_BODY (t);
1458 break;
1459 case COMPOUND_STMT:
1460 result_stmt_p = &COMPOUND_BODY (t);
1461 break;
1462 case TRY_FINALLY_EXPR:
1463 case TRY_CATCH_EXPR:
1464 case CLEANUP_STMT:
1465 result_stmt_p = &TREE_OPERAND (t, 0);
1466 break;
1467 default:
1468 abort ();
1469 }
a5bcc582 1470 }
325c3691 1471 type = TREE_TYPE (EXPR_STMT_EXPR (result_stmt));
a5bcc582 1472 }
6f80451c 1473
a5bcc582 1474 if (processing_template_decl)
325c3691
RH
1475 {
1476 result = build_min (STMT_EXPR, type, result);
1477 TREE_SIDE_EFFECTS (result) = 1;
1478 STMT_EXPR_NO_SCOPE (result) = has_no_scope;
1479 }
1480 else if (!VOID_TYPE_P (type))
a5bcc582
NS
1481 {
1482 /* Pull out the TARGET_EXPR that is the final expression. Put
1483 the target's init_expr as the final expression and then put
1484 the statement expression itself as the target's init
1485 expr. Finally, return the target expression. */
1486 tree last_expr = EXPR_STMT_EXPR (result_stmt);
1487
1488 my_friendly_assert (TREE_CODE (last_expr) == TARGET_EXPR, 20030729);
325c3691
RH
1489 *result_stmt_p = TREE_OPERAND (last_expr, 1);
1490
1491 if (TREE_CODE (result) == BIND_EXPR)
1492 {
1493 if (VOID_TYPE_P (TREE_TYPE (result)))
1494 TREE_TYPE (result) = TREE_TYPE (last_expr);
1495 else if (same_type_p (TREE_TYPE (result), TREE_TYPE (last_expr)))
1496 ;
1497 else
1498 abort ();
1499 }
1500 else if (TREE_CODE (result) == STATEMENT_LIST)
1501 result = build (BIND_EXPR, TREE_TYPE (last_expr), NULL, result, NULL);
1502
a5bcc582
NS
1503 TREE_OPERAND (last_expr, 1) = result;
1504 result = last_expr;
1505 }
325c3691 1506
b4c4a9ec
MM
1507 return result;
1508}
1509
b3445994 1510/* Perform Koenig lookup. FN is the postfix-expression representing
fa531100
MM
1511 the function (or functions) to call; ARGS are the arguments to the
1512 call. Returns the functions to be considered by overload
1513 resolution. */
b3445994
MM
1514
1515tree
1516perform_koenig_lookup (tree fn, tree args)
1517{
1518 tree identifier = NULL_TREE;
1519 tree functions = NULL_TREE;
1520
1521 /* Find the name of the overloaded function. */
1522 if (TREE_CODE (fn) == IDENTIFIER_NODE)
1523 identifier = fn;
1524 else if (is_overloaded_fn (fn))
1525 {
1526 functions = fn;
1527 identifier = DECL_NAME (get_first_fn (functions));
1528 }
1529 else if (DECL_P (fn))
1530 {
1531 functions = fn;
1532 identifier = DECL_NAME (fn);
1533 }
1534
1535 /* A call to a namespace-scope function using an unqualified name.
1536
1537 Do Koenig lookup -- unless any of the arguments are
1538 type-dependent. */
1539 if (!any_type_dependent_arguments_p (args))
1540 {
1541 fn = lookup_arg_dependent (identifier, functions, args);
1542 if (!fn)
1543 /* The unqualified name could not be resolved. */
1544 fn = unqualified_fn_lookup_error (identifier);
1545 }
1546 else
10b1d5e7 1547 fn = identifier;
b3445994
MM
1548
1549 return fn;
1550}
1551
4ba126e4
MM
1552/* Generate an expression for `FN (ARGS)'.
1553
1554 If DISALLOW_VIRTUAL is true, the call to FN will be not generated
1555 as a virtual call, even if FN is virtual. (This flag is set when
1556 encountering an expression where the function name is explicitly
1557 qualified. For example a call to `X::f' never generates a virtual
1558 call.)
1559
1560 Returns code for the call. */
b4c4a9ec
MM
1561
1562tree
6d80c4b9 1563finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p)
b4c4a9ec 1564{
d17811fd
MM
1565 tree result;
1566 tree orig_fn;
1567 tree orig_args;
1568
4ba126e4
MM
1569 if (fn == error_mark_node || args == error_mark_node)
1570 return error_mark_node;
1571
4ba126e4
MM
1572 /* ARGS should be a list of arguments. */
1573 my_friendly_assert (!args || TREE_CODE (args) == TREE_LIST,
1574 20020712);
a759e627 1575
d17811fd
MM
1576 orig_fn = fn;
1577 orig_args = args;
1578
1579 if (processing_template_decl)
1580 {
1581 if (type_dependent_expression_p (fn)
1582 || any_type_dependent_arguments_p (args))
6d80c4b9 1583 {
6de9cd9a 1584 result = build_nt (CALL_EXPR, fn, args, NULL_TREE);
6d80c4b9
MM
1585 KOENIG_LOOKUP_P (result) = koenig_p;
1586 return result;
1587 }
d17811fd
MM
1588 if (!BASELINK_P (fn)
1589 && TREE_CODE (fn) != PSEUDO_DTOR_EXPR
1590 && TREE_TYPE (fn) != unknown_type_node)
1591 fn = build_non_dependent_expr (fn);
1592 args = build_non_dependent_args (orig_args);
1593 }
1594
a723baf1
MM
1595 /* A reference to a member function will appear as an overloaded
1596 function (rather than a BASELINK) if an unqualified name was used
1597 to refer to it. */
1598 if (!BASELINK_P (fn) && is_overloaded_fn (fn))
1599 {
12483c9f 1600 tree f = fn;
a723baf1 1601
12483c9f
NS
1602 if (TREE_CODE (f) == TEMPLATE_ID_EXPR)
1603 f = TREE_OPERAND (f, 0);
1604 f = get_first_fn (f);
a723baf1
MM
1605 if (DECL_FUNCTION_MEMBER_P (f))
1606 {
1607 tree type = currently_open_derived_class (DECL_CONTEXT (f));
c44e68a5
KL
1608 if (!type)
1609 type = DECL_CONTEXT (f);
a723baf1
MM
1610 fn = build_baselink (TYPE_BINFO (type),
1611 TYPE_BINFO (type),
1612 fn, /*optype=*/NULL_TREE);
1613 }
1614 }
1615
d17811fd 1616 result = NULL_TREE;
4ba126e4 1617 if (BASELINK_P (fn))
03d82991 1618 {
4ba126e4
MM
1619 tree object;
1620
1621 /* A call to a member function. From [over.call.func]:
1622
1623 If the keyword this is in scope and refers to the class of
1624 that member function, or a derived class thereof, then the
1625 function call is transformed into a qualified function call
1626 using (*this) as the postfix-expression to the left of the
1627 . operator.... [Otherwise] a contrived object of type T
1628 becomes the implied object argument.
1629
1630 This paragraph is unclear about this situation:
1631
1632 struct A { void f(); };
1633 struct B : public A {};
1634 struct C : public A { void g() { B::f(); }};
1635
1636 In particular, for `B::f', this paragraph does not make clear
1637 whether "the class of that member function" refers to `A' or
1638 to `B'. We believe it refers to `B'. */
1639 if (current_class_type
1640 && DERIVED_FROM_P (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)),
1641 current_class_type)
1642 && current_class_ref)
127b8136
MM
1643 object = maybe_dummy_object (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)),
1644 NULL);
4ba126e4
MM
1645 else
1646 {
1647 tree representative_fn;
b4c4a9ec 1648
4ba126e4
MM
1649 representative_fn = BASELINK_FUNCTIONS (fn);
1650 if (TREE_CODE (representative_fn) == TEMPLATE_ID_EXPR)
1651 representative_fn = TREE_OPERAND (representative_fn, 0);
1652 representative_fn = get_first_fn (representative_fn);
1653 object = build_dummy_object (DECL_CONTEXT (representative_fn));
1654 }
b4c4a9ec 1655
d17811fd
MM
1656 if (processing_template_decl)
1657 {
1658 if (type_dependent_expression_p (object))
6de9cd9a 1659 return build_nt (CALL_EXPR, orig_fn, orig_args, NULL_TREE);
d17811fd
MM
1660 object = build_non_dependent_expr (object);
1661 }
1662
1663 result = build_new_method_call (object, fn, args, NULL_TREE,
1664 (disallow_virtual
1665 ? LOOKUP_NONVIRTUAL : 0));
4ba126e4
MM
1666 }
1667 else if (is_overloaded_fn (fn))
1668 /* A call to a namespace-scope function. */
d17811fd 1669 result = build_new_function_call (fn, args);
a723baf1
MM
1670 else if (TREE_CODE (fn) == PSEUDO_DTOR_EXPR)
1671 {
a723baf1
MM
1672 if (args)
1673 error ("arguments to destructor are not allowed");
1674 /* Mark the pseudo-destructor call as having side-effects so
1675 that we do not issue warnings about its use. */
1676 result = build1 (NOP_EXPR,
1677 void_type_node,
1678 TREE_OPERAND (fn, 0));
1679 TREE_SIDE_EFFECTS (result) = 1;
a723baf1 1680 }
4ba126e4 1681 else if (CLASS_TYPE_P (TREE_TYPE (fn)))
d17811fd
MM
1682 /* If the "function" is really an object of class type, it might
1683 have an overloaded `operator ()'. */
ec835fb2
MM
1684 result = build_new_op (CALL_EXPR, LOOKUP_NORMAL, fn, args, NULL_TREE,
1685 /*overloaded_p=*/NULL);
d17811fd
MM
1686 if (!result)
1687 /* A call where the function is unknown. */
1688 result = build_function_call (fn, args);
4ba126e4 1689
d17811fd 1690 if (processing_template_decl)
6d80c4b9 1691 {
6de9cd9a
DN
1692 result = build (CALL_EXPR, TREE_TYPE (result), orig_fn,
1693 orig_args, NULL_TREE);
6d80c4b9
MM
1694 KOENIG_LOOKUP_P (result) = koenig_p;
1695 }
d17811fd 1696 return result;
b4c4a9ec
MM
1697}
1698
1699/* Finish a call to a postfix increment or decrement or EXPR. (Which
1700 is indicated by CODE, which should be POSTINCREMENT_EXPR or
1701 POSTDECREMENT_EXPR.) */
1702
1703tree
3a978d72 1704finish_increment_expr (tree expr, enum tree_code code)
b4c4a9ec 1705{
b4c4a9ec
MM
1706 return build_x_unary_op (code, expr);
1707}
1708
1709/* Finish a use of `this'. Returns an expression for `this'. */
1710
1711tree
3a978d72 1712finish_this_expr (void)
b4c4a9ec
MM
1713{
1714 tree result;
1715
1716 if (current_class_ptr)
1717 {
b4c4a9ec
MM
1718 result = current_class_ptr;
1719 }
1720 else if (current_function_decl
1721 && DECL_STATIC_FUNCTION_P (current_function_decl))
1722 {
8251199e 1723 error ("`this' is unavailable for static member functions");
b4c4a9ec
MM
1724 result = error_mark_node;
1725 }
1726 else
1727 {
1728 if (current_function_decl)
8251199e 1729 error ("invalid use of `this' in non-member function");
b4c4a9ec 1730 else
8251199e 1731 error ("invalid use of `this' at top level");
b4c4a9ec
MM
1732 result = error_mark_node;
1733 }
1734
1735 return result;
1736}
1737
a723baf1
MM
1738/* Finish a pseudo-destructor expression. If SCOPE is NULL, the
1739 expression was of the form `OBJECT.~DESTRUCTOR' where DESTRUCTOR is
1740 the TYPE for the type given. If SCOPE is non-NULL, the expression
1741 was of the form `OBJECT.SCOPE::~DESTRUCTOR'. */
b4c4a9ec
MM
1742
1743tree
3a978d72 1744finish_pseudo_destructor_expr (tree object, tree scope, tree destructor)
b4c4a9ec 1745{
a723baf1
MM
1746 if (destructor == error_mark_node)
1747 return error_mark_node;
40242ccf 1748
a723baf1 1749 my_friendly_assert (TYPE_P (destructor), 20010905);
b4c4a9ec 1750
a723baf1
MM
1751 if (!processing_template_decl)
1752 {
1753 if (scope == error_mark_node)
1754 {
1755 error ("invalid qualifying scope in pseudo-destructor name");
1756 return error_mark_node;
1757 }
1758
26bcf8fc
MM
1759 /* [expr.pseudo] says both:
1760
1761 The type designated by the pseudo-destructor-name shall be
1762 the same as the object type.
1763
1764 and:
1765
1766 The cv-unqualified versions of the object type and of the
1767 type designated by the pseudo-destructor-name shall be the
1768 same type.
1769
1770 We implement the more generous second sentence, since that is
1771 what most other compilers do. */
1772 if (!same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (object),
1773 destructor))
a723baf1
MM
1774 {
1775 error ("`%E' is not of type `%T'", object, destructor);
1776 return error_mark_node;
1777 }
1778 }
b4c4a9ec 1779
a723baf1 1780 return build (PSEUDO_DTOR_EXPR, void_type_node, object, scope, destructor);
b4c4a9ec
MM
1781}
1782
ce4a0391
MM
1783/* Finish an expression of the form CODE EXPR. */
1784
1785tree
3a978d72 1786finish_unary_op_expr (enum tree_code code, tree expr)
ce4a0391
MM
1787{
1788 tree result = build_x_unary_op (code, expr);
7c355bca
ML
1789 /* Inside a template, build_x_unary_op does not fold the
1790 expression. So check whether the result is folded before
1791 setting TREE_NEGATED_INT. */
1792 if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST
88b4335f 1793 && TREE_CODE (result) == INTEGER_CST
8df83eae 1794 && !TYPE_UNSIGNED (TREE_TYPE (result))
88b4335f 1795 && INT_CST_LT (result, integer_zero_node))
ce4a0391
MM
1796 TREE_NEGATED_INT (result) = 1;
1797 overflow_warning (result);
1798 return result;
1799}
1800
a723baf1
MM
1801/* Finish a compound-literal expression. TYPE is the type to which
1802 the INITIALIZER_LIST is being cast. */
1803
1804tree
3a978d72 1805finish_compound_literal (tree type, tree initializer_list)
a723baf1
MM
1806{
1807 tree compound_literal;
1808
1809 /* Build a CONSTRUCTOR for the INITIALIZER_LIST. */
dcf92453 1810 compound_literal = build_constructor (NULL_TREE, initializer_list);
a723baf1
MM
1811 /* Mark it as a compound-literal. */
1812 TREE_HAS_CONSTRUCTOR (compound_literal) = 1;
1813 if (processing_template_decl)
1814 TREE_TYPE (compound_literal) = type;
1815 else
1816 {
1817 /* Check the initialization. */
1818 compound_literal = digest_init (type, compound_literal, NULL);
1819 /* If the TYPE was an array type with an unknown bound, then we can
1820 figure out the dimension now. For example, something like:
1821
1822 `(int []) { 2, 3 }'
1823
1824 implies that the array has two elements. */
1825 if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
1826 complete_array_type (type, compound_literal, 1);
1827 }
1828
1829 return compound_literal;
1830}
1831
5f261ba9
MM
1832/* Return the declaration for the function-name variable indicated by
1833 ID. */
1834
1835tree
1836finish_fname (tree id)
1837{
1838 tree decl;
1839
1840 decl = fname_decl (C_RID_CODE (id), id);
1841 if (processing_template_decl)
10b1d5e7 1842 decl = DECL_NAME (decl);
5f261ba9
MM
1843 return decl;
1844}
1845
15c7fb9c 1846/* Begin a function definition declared with DECL_SPECS, ATTRIBUTES,
838dfd8a 1847 and DECLARATOR. Returns nonzero if the function-declaration is
0e339752 1848 valid. */
b4c4a9ec
MM
1849
1850int
3a978d72 1851begin_function_definition (tree decl_specs, tree attributes, tree declarator)
b4c4a9ec 1852{
15c7fb9c 1853 if (!start_function (decl_specs, declarator, attributes, SF_DEFAULT))
b4c4a9ec 1854 return 0;
1f51a992 1855
39c01e4c
MM
1856 /* The things we're about to see are not directly qualified by any
1857 template headers we've seen thus far. */
1858 reset_specialization ();
1859
b4c4a9ec
MM
1860 return 1;
1861}
1862
8014a339 1863/* Finish a translation unit. */
ce4a0391
MM
1864
1865void
3a978d72 1866finish_translation_unit (void)
ce4a0391
MM
1867{
1868 /* In case there were missing closebraces,
1869 get us back to the global binding level. */
273a708f 1870 pop_everything ();
ce4a0391
MM
1871 while (current_namespace != global_namespace)
1872 pop_namespace ();
0ba8a114 1873
c6002625 1874 /* Do file scope __FUNCTION__ et al. */
0ba8a114 1875 finish_fname_decls ();
ce4a0391
MM
1876}
1877
b4c4a9ec
MM
1878/* Finish a template type parameter, specified as AGGR IDENTIFIER.
1879 Returns the parameter. */
1880
1881tree
3a978d72 1882finish_template_type_parm (tree aggr, tree identifier)
b4c4a9ec 1883{
6eabb241 1884 if (aggr != class_type_node)
b4c4a9ec 1885 {
8251199e 1886 pedwarn ("template type parameters must use the keyword `class' or `typename'");
b4c4a9ec
MM
1887 aggr = class_type_node;
1888 }
1889
1890 return build_tree_list (aggr, identifier);
1891}
1892
1893/* Finish a template template parameter, specified as AGGR IDENTIFIER.
1894 Returns the parameter. */
1895
1896tree
3a978d72 1897finish_template_template_parm (tree aggr, tree identifier)
b4c4a9ec
MM
1898{
1899 tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
1900 tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
1901 DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
1902 DECL_TEMPLATE_RESULT (tmpl) = decl;
c727aa5e 1903 DECL_ARTIFICIAL (decl) = 1;
b4c4a9ec
MM
1904 end_template_decl ();
1905
b37bf5bd
NS
1906 my_friendly_assert (DECL_TEMPLATE_PARMS (tmpl), 20010110);
1907
b4c4a9ec
MM
1908 return finish_template_type_parm (aggr, tmpl);
1909}
ce4a0391 1910
8ba658ee
MM
1911/* ARGUMENT is the default-argument value for a template template
1912 parameter. If ARGUMENT is invalid, issue error messages and return
1913 the ERROR_MARK_NODE. Otherwise, ARGUMENT itself is returned. */
1914
1915tree
1916check_template_template_default_arg (tree argument)
1917{
1918 if (TREE_CODE (argument) != TEMPLATE_DECL
1919 && TREE_CODE (argument) != TEMPLATE_TEMPLATE_PARM
8ba658ee
MM
1920 && TREE_CODE (argument) != UNBOUND_CLASS_TEMPLATE)
1921 {
a3a503a5
GB
1922 if (TREE_CODE (argument) == TYPE_DECL)
1923 {
1924 tree t = TREE_TYPE (argument);
1925
1926 /* Try to emit a slightly smarter error message if we detect
1927 that the user is using a template instantiation. */
1928 if (CLASSTYPE_TEMPLATE_INFO (t)
1929 && CLASSTYPE_TEMPLATE_INSTANTIATION (t))
1930 error ("invalid use of type `%T' as a default value for a "
1931 "template template-parameter", t);
1932 else
1933 error ("invalid use of `%D' as a default value for a template "
1934 "template-parameter", argument);
1935 }
1936 else
1937 error ("invalid default argument for a template template parameter");
8ba658ee
MM
1938 return error_mark_node;
1939 }
1940
1941 return argument;
1942}
1943
ce4a0391 1944/* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
838dfd8a 1945 nonzero, the parameter list was terminated by a `...'. */
ce4a0391
MM
1946
1947tree
3a978d72 1948finish_parmlist (tree parms, int ellipsis)
ce4a0391 1949{
5cce22b6
NS
1950 if (parms)
1951 {
1952 /* We mark the PARMS as a parmlist so that declarator processing can
1953 disambiguate certain constructs. */
1954 TREE_PARMLIST (parms) = 1;
1955 /* We do not append void_list_node here, but leave it to grokparms
1956 to do that. */
1957 PARMLIST_ELLIPSIS_P (parms) = ellipsis;
1958 }
ce4a0391
MM
1959 return parms;
1960}
1961
1962/* Begin a class definition, as indicated by T. */
1963
1964tree
3a978d72 1965begin_class_definition (tree t)
ce4a0391 1966{
7437519c
ZW
1967 if (t == error_mark_node)
1968 return error_mark_node;
1969
522d6614
NS
1970 if (processing_template_parmlist)
1971 {
33bd39a2 1972 error ("definition of `%#T' inside template parameter list", t);
522d6614
NS
1973 return error_mark_node;
1974 }
47ee8904
MM
1975 /* A non-implicit typename comes from code like:
1976
1977 template <typename T> struct A {
1978 template <typename U> struct A<T>::B ...
1979
1980 This is erroneous. */
1981 else if (TREE_CODE (t) == TYPENAME_TYPE)
1982 {
33bd39a2 1983 error ("invalid definition of qualified type `%T'", t);
47ee8904
MM
1984 t = error_mark_node;
1985 }
1986
1987 if (t == error_mark_node || ! IS_AGGR_TYPE (t))
ce4a0391 1988 {
33848bb0 1989 t = make_aggr_type (RECORD_TYPE);
ce4a0391
MM
1990 pushtag (make_anon_name (), t, 0);
1991 }
830fcda8 1992
4c571114
MM
1993 /* If this type was already complete, and we see another definition,
1994 that's an error. */
8fbc5ae7 1995 if (COMPLETE_TYPE_P (t))
4223f82f
MM
1996 {
1997 error ("redefinition of `%#T'", t);
1998 cp_error_at ("previous definition of `%#T'", t);
1999 return error_mark_node;
2000 }
4c571114 2001
b4f70b3d 2002 /* Update the location of the decl. */
f31686a3 2003 DECL_SOURCE_LOCATION (TYPE_NAME (t)) = input_location;
b4f70b3d 2004
4c571114 2005 if (TYPE_BEING_DEFINED (t))
ce4a0391 2006 {
33848bb0 2007 t = make_aggr_type (TREE_CODE (t));
ce4a0391 2008 pushtag (TYPE_IDENTIFIER (t), t, 0);
ce4a0391 2009 }
ff350acd 2010 maybe_process_partial_specialization (t);
29370796 2011 pushclass (t);
ce4a0391 2012 TYPE_BEING_DEFINED (t) = 1;
c0694c4b
MM
2013 if (flag_pack_struct)
2014 {
2015 tree v;
2016 TYPE_PACKED (t) = 1;
2017 /* Even though the type is being defined for the first time
2018 here, there might have been a forward declaration, so there
2019 might be cv-qualified variants of T. */
2020 for (v = TYPE_NEXT_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v))
2021 TYPE_PACKED (v) = 1;
2022 }
ce4a0391
MM
2023 /* Reset the interface data, at the earliest possible
2024 moment, as it might have been set via a class foo;
2025 before. */
1951a1b6
JM
2026 if (! TYPE_ANONYMOUS_P (t))
2027 {
2028 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
2029 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
2030 (t, interface_unknown);
2031 }
ce4a0391
MM
2032 reset_specialization();
2033
b7975aed
MM
2034 /* Make a declaration for this class in its own scope. */
2035 build_self_reference ();
2036
830fcda8 2037 return t;
ce4a0391
MM
2038}
2039
61a127b3
MM
2040/* Finish the member declaration given by DECL. */
2041
2042void
3a978d72 2043finish_member_declaration (tree decl)
61a127b3
MM
2044{
2045 if (decl == error_mark_node || decl == NULL_TREE)
2046 return;
2047
2048 if (decl == void_type_node)
2049 /* The COMPONENT was a friend, not a member, and so there's
2050 nothing for us to do. */
2051 return;
2052
2053 /* We should see only one DECL at a time. */
2054 my_friendly_assert (TREE_CHAIN (decl) == NULL_TREE, 0);
2055
2056 /* Set up access control for DECL. */
2057 TREE_PRIVATE (decl)
2058 = (current_access_specifier == access_private_node);
2059 TREE_PROTECTED (decl)
2060 = (current_access_specifier == access_protected_node);
2061 if (TREE_CODE (decl) == TEMPLATE_DECL)
2062 {
17aec3eb
RK
2063 TREE_PRIVATE (DECL_TEMPLATE_RESULT (decl)) = TREE_PRIVATE (decl);
2064 TREE_PROTECTED (DECL_TEMPLATE_RESULT (decl)) = TREE_PROTECTED (decl);
61a127b3
MM
2065 }
2066
2067 /* Mark the DECL as a member of the current class. */
4f1c5b7d 2068 DECL_CONTEXT (decl) = current_class_type;
61a127b3 2069
421844e7
MM
2070 /* [dcl.link]
2071
2072 A C language linkage is ignored for the names of class members
2073 and the member function type of class member functions. */
2074 if (DECL_LANG_SPECIFIC (decl) && DECL_LANGUAGE (decl) == lang_c)
5d2ed28c 2075 SET_DECL_LANGUAGE (decl, lang_cplusplus);
421844e7 2076
61a127b3
MM
2077 /* Put functions on the TYPE_METHODS list and everything else on the
2078 TYPE_FIELDS list. Note that these are built up in reverse order.
2079 We reverse them (to obtain declaration order) in finish_struct. */
2080 if (TREE_CODE (decl) == FUNCTION_DECL
2081 || DECL_FUNCTION_TEMPLATE_P (decl))
2082 {
2083 /* We also need to add this function to the
2084 CLASSTYPE_METHOD_VEC. */
452a394b 2085 add_method (current_class_type, decl, /*error_p=*/0);
61a127b3
MM
2086
2087 TREE_CHAIN (decl) = TYPE_METHODS (current_class_type);
2088 TYPE_METHODS (current_class_type) = decl;
f139561c
MM
2089
2090 maybe_add_class_template_decl_list (current_class_type, decl,
2091 /*friend_p=*/0);
61a127b3 2092 }
f139561c 2093 /* Enter the DECL into the scope of the class. */
fd9aef9d 2094 else if ((TREE_CODE (decl) == USING_DECL && TREE_TYPE (decl))
399dedb9 2095 || pushdecl_class_level (decl))
61a127b3
MM
2096 {
2097 /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
2098 go at the beginning. The reason is that lookup_field_1
2099 searches the list in order, and we want a field name to
2100 override a type name so that the "struct stat hack" will
2101 work. In particular:
2102
2103 struct S { enum E { }; int E } s;
2104 s.E = 3;
2105
0e339752 2106 is valid. In addition, the FIELD_DECLs must be maintained in
61a127b3
MM
2107 declaration order so that class layout works as expected.
2108 However, we don't need that order until class layout, so we
2109 save a little time by putting FIELD_DECLs on in reverse order
2110 here, and then reversing them in finish_struct_1. (We could
2111 also keep a pointer to the correct insertion points in the
2112 list.) */
2113
2114 if (TREE_CODE (decl) == TYPE_DECL)
2115 TYPE_FIELDS (current_class_type)
2116 = chainon (TYPE_FIELDS (current_class_type), decl);
2117 else
2118 {
2119 TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type);
2120 TYPE_FIELDS (current_class_type) = decl;
2121 }
8f032717 2122
f139561c
MM
2123 maybe_add_class_template_decl_list (current_class_type, decl,
2124 /*friend_p=*/0);
61a127b3
MM
2125 }
2126}
2127
35acd3f2
MM
2128/* Finish processing the declaration of a member class template
2129 TYPES whose template parameters are given by PARMS. */
2130
2131tree
3a978d72 2132finish_member_class_template (tree types)
35acd3f2 2133{
36a117a5
MM
2134 tree t;
2135
2136 /* If there are declared, but undefined, partial specializations
2137 mixed in with the typespecs they will not yet have passed through
2138 maybe_process_partial_specialization, so we do that here. */
2139 for (t = types; t != NULL_TREE; t = TREE_CHAIN (t))
2140 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t))))
2141 maybe_process_partial_specialization (TREE_VALUE (t));
2142
61a127b3 2143 grok_x_components (types);
35acd3f2
MM
2144 if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type)
2145 /* The component was in fact a friend declaration. We avoid
2146 finish_member_template_decl performing certain checks by
2147 unsetting TYPES. */
2148 types = NULL_TREE;
61a127b3
MM
2149
2150 finish_member_template_decl (types);
2151
35acd3f2
MM
2152 /* As with other component type declarations, we do
2153 not store the new DECL on the list of
2154 component_decls. */
2155 return NULL_TREE;
2156}
36a117a5 2157
306ef644 2158/* Finish processing a complete template declaration. The PARMS are
36a117a5
MM
2159 the template parameters. */
2160
2161void
3a978d72 2162finish_template_decl (tree parms)
36a117a5
MM
2163{
2164 if (parms)
2165 end_template_decl ();
2166 else
2167 end_specialization ();
2168}
2169
509fc277 2170/* Finish processing a template-id (which names a type) of the form
36a117a5 2171 NAME < ARGS >. Return the TYPE_DECL for the type named by the
838dfd8a 2172 template-id. If ENTERING_SCOPE is nonzero we are about to enter
36a117a5
MM
2173 the scope of template-id indicated. */
2174
2175tree
3a978d72 2176finish_template_type (tree name, tree args, int entering_scope)
36a117a5
MM
2177{
2178 tree decl;
2179
2180 decl = lookup_template_class (name, args,
42eaed49
NS
2181 NULL_TREE, NULL_TREE, entering_scope,
2182 tf_error | tf_warning | tf_user);
36a117a5
MM
2183 if (decl != error_mark_node)
2184 decl = TYPE_STUB_DECL (decl);
2185
2186 return decl;
2187}
648f19f6 2188
ea6021e8
MM
2189/* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER.
2190 Return a TREE_LIST containing the ACCESS_SPECIFIER and the
2191 BASE_CLASS, or NULL_TREE if an error occurred. The
aba649ba 2192 ACCESS_SPECIFIER is one of
ea6021e8
MM
2193 access_{default,public,protected_private}[_virtual]_node.*/
2194
2195tree
dbbf88d1 2196finish_base_specifier (tree base, tree access, bool virtual_p)
ea6021e8 2197{
ea6021e8
MM
2198 tree result;
2199
dbbf88d1 2200 if (base == error_mark_node)
acb044ee
GDR
2201 {
2202 error ("invalid base-class specification");
2203 result = NULL_TREE;
2204 }
dbbf88d1 2205 else if (! is_aggr_type (base, 1))
ea6021e8 2206 result = NULL_TREE;
ea6021e8 2207 else
bb92901d 2208 {
dbbf88d1 2209 if (cp_type_quals (base) != 0)
bb92901d 2210 {
dbbf88d1
NS
2211 error ("base class `%T' has cv qualifiers", base);
2212 base = TYPE_MAIN_VARIANT (base);
bb92901d 2213 }
dbbf88d1
NS
2214 result = build_tree_list (access, base);
2215 TREE_VIA_VIRTUAL (result) = virtual_p;
bb92901d 2216 }
ea6021e8
MM
2217
2218 return result;
2219}
61a127b3
MM
2220
2221/* Called when multiple declarators are processed. If that is not
cd0be382 2222 permitted in this context, an error is issued. */
61a127b3
MM
2223
2224void
3a978d72 2225check_multiple_declarators (void)
61a127b3
MM
2226{
2227 /* [temp]
2228
2229 In a template-declaration, explicit specialization, or explicit
2230 instantiation the init-declarator-list in the declaration shall
2231 contain at most one declarator.
2232
2233 We don't just use PROCESSING_TEMPLATE_DECL for the first
0e339752 2234 condition since that would disallow the perfectly valid code,
61a127b3 2235 like `template <class T> struct S { int i, j; };'. */
5f261ba9 2236 if (at_function_scope_p ())
61a127b3
MM
2237 /* It's OK to write `template <class T> void f() { int i, j;}'. */
2238 return;
2239
2240 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
2241 || processing_explicit_instantiation
2242 || processing_specialization)
33bd39a2 2243 error ("multiple declarators in template declaration");
61a127b3
MM
2244}
2245
22038b2c
NS
2246/* Issue a diagnostic that NAME cannot be found in SCOPE. */
2247
2248void
2249qualified_name_lookup_error (tree scope, tree name)
2250{
2251 if (TYPE_P (scope))
2252 {
2253 if (!COMPLETE_TYPE_P (scope))
2254 error ("incomplete type `%T' used in nested name specifier", scope);
2255 else
2256 error ("`%D' is not a member of `%T'", name, scope);
2257 }
2258 else if (scope != global_namespace)
2259 error ("`%D' is not a member of `%D'", name, scope);
2260 else
2261 error ("`::%D' has not been declared", name);
2262}
2263
b3445994
MM
2264/* ID_EXPRESSION is a representation of parsed, but unprocessed,
2265 id-expression. (See cp_parser_id_expression for details.) SCOPE,
2266 if non-NULL, is the type or namespace used to explicitly qualify
2267 ID_EXPRESSION. DECL is the entity to which that name has been
2268 resolved.
2269
2270 *CONSTANT_EXPRESSION_P is true if we are presently parsing a
2271 constant-expression. In that case, *NON_CONSTANT_EXPRESSION_P will
2272 be set to true if this expression isn't permitted in a
2273 constant-expression, but it is otherwise not set by this function.
2274 *ALLOW_NON_CONSTANT_EXPRESSION_P is true if we are parsing a
2275 constant-expression, but a non-constant expression is also
2276 permissible.
2277
2278 If an error occurs, and it is the kind of error that might cause
2279 the parser to abort a tentative parse, *ERROR_MSG is filled in. It
2280 is the caller's responsibility to issue the message. *ERROR_MSG
2281 will be a string with static storage duration, so the caller need
2282 not "free" it.
2283
2284 Return an expression for the entity, after issuing appropriate
2285 diagnostics. This function is also responsible for transforming a
2286 reference to a non-static member into a COMPONENT_REF that makes
2287 the use of "this" explicit.
2288
2289 Upon return, *IDK will be filled in appropriately. */
2290
2291tree
2292finish_id_expression (tree id_expression,
2293 tree decl,
2294 tree scope,
2295 cp_id_kind *idk,
2296 tree *qualifying_class,
67c03833
JM
2297 bool integral_constant_expression_p,
2298 bool allow_non_integral_constant_expression_p,
2299 bool *non_integral_constant_expression_p,
b3445994
MM
2300 const char **error_msg)
2301{
2302 /* Initialize the output parameters. */
2303 *idk = CP_ID_KIND_NONE;
2304 *error_msg = NULL;
2305
2306 if (id_expression == error_mark_node)
2307 return error_mark_node;
2308 /* If we have a template-id, then no further lookup is
2309 required. If the template-id was for a template-class, we
2310 will sometimes have a TYPE_DECL at this point. */
2311 else if (TREE_CODE (decl) == TEMPLATE_ID_EXPR
ee935db4 2312 || TREE_CODE (decl) == TYPE_DECL)
b3445994
MM
2313 ;
2314 /* Look up the name. */
2315 else
2316 {
2317 if (decl == error_mark_node)
2318 {
2319 /* Name lookup failed. */
4546865e
MM
2320 if (scope
2321 && (!TYPE_P (scope)
2322 || (!dependent_type_p (scope)
2323 && !(TREE_CODE (id_expression) == IDENTIFIER_NODE
2324 && IDENTIFIER_TYPENAME_P (id_expression)
2325 && dependent_type_p (TREE_TYPE (id_expression))))))
b3445994 2326 {
4546865e
MM
2327 /* If the qualifying type is non-dependent (and the name
2328 does not name a conversion operator to a dependent
2329 type), issue an error. */
22038b2c 2330 qualified_name_lookup_error (scope, id_expression);
b3445994
MM
2331 return error_mark_node;
2332 }
2333 else if (!scope)
2334 {
2335 /* It may be resolved via Koenig lookup. */
2336 *idk = CP_ID_KIND_UNQUALIFIED;
2337 return id_expression;
2338 }
4546865e
MM
2339 else
2340 decl = id_expression;
b3445994
MM
2341 }
2342 /* If DECL is a variable that would be out of scope under
2343 ANSI/ISO rules, but in scope in the ARM, name lookup
2344 will succeed. Issue a diagnostic here. */
2345 else
2346 decl = check_for_out_of_scope_variable (decl);
2347
2348 /* Remember that the name was used in the definition of
2349 the current class so that we can check later to see if
2350 the meaning would have been different after the class
2351 was entirely defined. */
2352 if (!scope && decl != error_mark_node)
2353 maybe_note_name_used_in_class (id_expression, decl);
2354 }
2355
2356 /* If we didn't find anything, or what we found was a type,
2357 then this wasn't really an id-expression. */
2358 if (TREE_CODE (decl) == TEMPLATE_DECL
2359 && !DECL_FUNCTION_TEMPLATE_P (decl))
2360 {
2361 *error_msg = "missing template arguments";
2362 return error_mark_node;
2363 }
2364 else if (TREE_CODE (decl) == TYPE_DECL
2365 || TREE_CODE (decl) == NAMESPACE_DECL)
2366 {
2367 *error_msg = "expected primary-expression";
2368 return error_mark_node;
2369 }
2370
2371 /* If the name resolved to a template parameter, there is no
931a9c05
GB
2372 need to look it up again later. */
2373 if ((TREE_CODE (decl) == CONST_DECL && DECL_TEMPLATE_PARM_P (decl))
2374 || TREE_CODE (decl) == TEMPLATE_PARM_INDEX)
b3445994
MM
2375 {
2376 *idk = CP_ID_KIND_NONE;
931a9c05
GB
2377 if (TREE_CODE (decl) == TEMPLATE_PARM_INDEX)
2378 decl = TEMPLATE_PARM_DECL (decl);
67c03833 2379 if (integral_constant_expression_p
68deab91 2380 && !dependent_type_p (TREE_TYPE (decl))
931a9c05
GB
2381 && !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (decl)))
2382 {
67c03833 2383 if (!allow_non_integral_constant_expression_p)
931a9c05
GB
2384 error ("template parameter `%D' of type `%T' is not allowed in "
2385 "an integral constant expression because it is not of "
2386 "integral or enumeration type", decl, TREE_TYPE (decl));
67c03833 2387 *non_integral_constant_expression_p = true;
931a9c05
GB
2388 }
2389 return DECL_INITIAL (decl);
2390 }
2391 /* Similarly, we resolve enumeration constants to their
2392 underlying values. */
2393 else if (TREE_CODE (decl) == CONST_DECL)
2394 {
2395 *idk = CP_ID_KIND_NONE;
2396 if (!processing_template_decl)
b3445994
MM
2397 return DECL_INITIAL (decl);
2398 return decl;
2399 }
2400 else
2401 {
2402 bool dependent_p;
2403
2404 /* If the declaration was explicitly qualified indicate
2405 that. The semantics of `A::f(3)' are different than
2406 `f(3)' if `f' is virtual. */
2407 *idk = (scope
2408 ? CP_ID_KIND_QUALIFIED
2409 : (TREE_CODE (decl) == TEMPLATE_ID_EXPR
2410 ? CP_ID_KIND_TEMPLATE_ID
2411 : CP_ID_KIND_UNQUALIFIED));
2412
2413
2414 /* [temp.dep.expr]
2415
2416 An id-expression is type-dependent if it contains an
2417 identifier that was declared with a dependent type.
2418
b3445994
MM
2419 The standard is not very specific about an id-expression that
2420 names a set of overloaded functions. What if some of them
2421 have dependent types and some of them do not? Presumably,
2422 such a name should be treated as a dependent name. */
2423 /* Assume the name is not dependent. */
2424 dependent_p = false;
2425 if (!processing_template_decl)
2426 /* No names are dependent outside a template. */
2427 ;
2428 /* A template-id where the name of the template was not resolved
2429 is definitely dependent. */
2430 else if (TREE_CODE (decl) == TEMPLATE_ID_EXPR
2431 && (TREE_CODE (TREE_OPERAND (decl, 0))
2432 == IDENTIFIER_NODE))
2433 dependent_p = true;
2434 /* For anything except an overloaded function, just check its
2435 type. */
2436 else if (!is_overloaded_fn (decl))
2437 dependent_p
2438 = dependent_type_p (TREE_TYPE (decl));
2439 /* For a set of overloaded functions, check each of the
2440 functions. */
2441 else
2442 {
2443 tree fns = decl;
2444
2445 if (BASELINK_P (fns))
2446 fns = BASELINK_FUNCTIONS (fns);
2447
2448 /* For a template-id, check to see if the template
2449 arguments are dependent. */
2450 if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
2451 {
2452 tree args = TREE_OPERAND (fns, 1);
2453 dependent_p = any_dependent_template_arguments_p (args);
2454 /* The functions are those referred to by the
2455 template-id. */
2456 fns = TREE_OPERAND (fns, 0);
2457 }
2458
2459 /* If there are no dependent template arguments, go through
cd0be382 2460 the overloaded functions. */
b3445994
MM
2461 while (fns && !dependent_p)
2462 {
2463 tree fn = OVL_CURRENT (fns);
2464
2465 /* Member functions of dependent classes are
2466 dependent. */
2467 if (TREE_CODE (fn) == FUNCTION_DECL
2468 && type_dependent_expression_p (fn))
2469 dependent_p = true;
2470 else if (TREE_CODE (fn) == TEMPLATE_DECL
2471 && dependent_template_p (fn))
2472 dependent_p = true;
2473
2474 fns = OVL_NEXT (fns);
2475 }
2476 }
2477
2478 /* If the name was dependent on a template parameter, we will
2479 resolve the name at instantiation time. */
2480 if (dependent_p)
2481 {
2482 /* Create a SCOPE_REF for qualified names, if the scope is
2483 dependent. */
2484 if (scope)
2485 {
2486 if (TYPE_P (scope))
2487 *qualifying_class = scope;
2488 /* Since this name was dependent, the expression isn't
2489 constant -- yet. No error is issued because it might
2490 be constant when things are instantiated. */
67c03833
JM
2491 if (integral_constant_expression_p)
2492 *non_integral_constant_expression_p = true;
b3445994
MM
2493 if (TYPE_P (scope) && dependent_type_p (scope))
2494 return build_nt (SCOPE_REF, scope, id_expression);
2495 else if (TYPE_P (scope) && DECL_P (decl))
2496 return build (SCOPE_REF, TREE_TYPE (decl), scope,
2497 id_expression);
2498 else
2499 return decl;
2500 }
2501 /* A TEMPLATE_ID already contains all the information we
2502 need. */
2503 if (TREE_CODE (id_expression) == TEMPLATE_ID_EXPR)
2504 return id_expression;
2505 /* Since this name was dependent, the expression isn't
2506 constant -- yet. No error is issued because it might be
2507 constant when things are instantiated. */
67c03833
JM
2508 if (integral_constant_expression_p)
2509 *non_integral_constant_expression_p = true;
10b1d5e7 2510 *idk = CP_ID_KIND_UNQUALIFIED_DEPENDENT;
5a98fa7b
MM
2511 /* If we found a variable, then name lookup during the
2512 instantiation will always resolve to the same VAR_DECL
2513 (or an instantiation thereof). */
3c398f34
MM
2514 if (TREE_CODE (decl) == VAR_DECL
2515 || TREE_CODE (decl) == PARM_DECL)
5a98fa7b 2516 return decl;
10b1d5e7 2517 return id_expression;
b3445994
MM
2518 }
2519
2520 /* Only certain kinds of names are allowed in constant
931a9c05
GB
2521 expression. Enumerators and template parameters
2522 have already been handled above. */
67c03833 2523 if (integral_constant_expression_p)
b3445994 2524 {
931a9c05
GB
2525 /* Const variables or static data members of integral or
2526 enumeration types initialized with constant expressions
2527 are OK. */
2528 if (TREE_CODE (decl) == VAR_DECL
2529 && CP_TYPE_CONST_P (TREE_TYPE (decl))
2530 && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (decl))
2531 && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
b3445994
MM
2532 ;
2533 else
2534 {
67c03833 2535 if (!allow_non_integral_constant_expression_p)
b3445994
MM
2536 {
2537 error ("`%D' cannot appear in a constant-expression", decl);
2538 return error_mark_node;
2539 }
67c03833 2540 *non_integral_constant_expression_p = true;
b3445994
MM
2541 }
2542 }
415d4636
MM
2543
2544 if (TREE_CODE (decl) == NAMESPACE_DECL)
9e95d15f
NS
2545 {
2546 error ("use of namespace `%D' as expression", decl);
2547 return error_mark_node;
2548 }
2549 else if (DECL_CLASS_TEMPLATE_P (decl))
2550 {
2551 error ("use of class template `%T' as expression", decl);
2552 return error_mark_node;
2553 }
2554 else if (TREE_CODE (decl) == TREE_LIST)
2555 {
2556 /* Ambiguous reference to base members. */
2557 error ("request for member `%D' is ambiguous in "
2558 "multiple inheritance lattice", id_expression);
2559 print_candidates (decl);
2560 return error_mark_node;
2561 }
415d4636
MM
2562
2563 /* Mark variable-like entities as used. Functions are similarly
2564 marked either below or after overload resolution. */
2565 if (TREE_CODE (decl) == VAR_DECL
2566 || TREE_CODE (decl) == PARM_DECL
2567 || TREE_CODE (decl) == RESULT_DECL)
2568 mark_used (decl);
2569
2570 if (scope)
2571 {
2572 decl = (adjust_result_of_qualified_name_lookup
2573 (decl, scope, current_class_type));
e20bcc5e
JH
2574
2575 if (TREE_CODE (decl) == FUNCTION_DECL)
2576 mark_used (decl);
2577
415d4636
MM
2578 if (TREE_CODE (decl) == FIELD_DECL || BASELINK_P (decl))
2579 *qualifying_class = scope;
2580 else if (!processing_template_decl)
2581 decl = convert_from_reference (decl);
2582 else if (TYPE_P (scope))
2583 decl = build (SCOPE_REF, TREE_TYPE (decl), scope, decl);
2584 }
9e95d15f
NS
2585 else if (TREE_CODE (decl) == FIELD_DECL)
2586 decl = finish_non_static_data_member (decl, current_class_ref,
2587 /*qualifying_scope=*/NULL_TREE);
2588 else if (is_overloaded_fn (decl))
2589 {
2590 tree first_fn = OVL_CURRENT (decl);
b3445994 2591
9e95d15f
NS
2592 if (TREE_CODE (first_fn) == TEMPLATE_DECL)
2593 first_fn = DECL_TEMPLATE_RESULT (first_fn);
415d4636
MM
2594
2595 if (!really_overloaded_fn (decl))
2596 mark_used (first_fn);
2597
9e95d15f
NS
2598 if (TREE_CODE (first_fn) == FUNCTION_DECL
2599 && DECL_FUNCTION_MEMBER_P (first_fn))
2600 {
2601 /* A set of member functions. */
2602 decl = maybe_dummy_object (DECL_CONTEXT (first_fn), 0);
2603 return finish_class_member_access_expr (decl, id_expression);
2604 }
9e95d15f
NS
2605 }
2606 else
2607 {
2608 if (TREE_CODE (decl) == VAR_DECL
2609 || TREE_CODE (decl) == PARM_DECL
2610 || TREE_CODE (decl) == RESULT_DECL)
2611 {
2612 tree context = decl_function_context (decl);
2613
2614 if (context != NULL_TREE && context != current_function_decl
2615 && ! TREE_STATIC (decl))
2616 {
2617 error ("use of %s from containing function",
2618 (TREE_CODE (decl) == VAR_DECL
2619 ? "`auto' variable" : "parameter"));
2620 cp_error_at (" `%#D' declared here", decl);
2621 return error_mark_node;
2622 }
2623 }
2624
2625 if (DECL_P (decl) && DECL_NONLOCAL (decl)
2626 && DECL_CLASS_SCOPE_P (decl)
2627 && DECL_CONTEXT (decl) != current_class_type)
2628 {
2629 tree path;
2630
2631 path = currently_open_derived_class (DECL_CONTEXT (decl));
2632 perform_or_defer_access_check (TYPE_BINFO (path), decl);
2633 }
2634
9e95d15f
NS
2635 if (! processing_template_decl)
2636 decl = convert_from_reference (decl);
2637 }
2638
b3445994
MM
2639 /* Resolve references to variables of anonymous unions
2640 into COMPONENT_REFs. */
2641 if (TREE_CODE (decl) == ALIAS_DECL)
6de9cd9a 2642 decl = unshare_expr (DECL_INITIAL (decl));
b3445994
MM
2643 }
2644
2645 if (TREE_DEPRECATED (decl))
2646 warn_deprecated_use (decl);
2647
2648 return decl;
2649}
2650
0213a355
JM
2651/* Implement the __typeof keyword: Return the type of EXPR, suitable for
2652 use as a type-specifier. */
2653
b894fc05 2654tree
3a978d72 2655finish_typeof (tree expr)
b894fc05 2656{
65a5559b
MM
2657 tree type;
2658
dffbbe80 2659 if (type_dependent_expression_p (expr))
b894fc05 2660 {
65a5559b 2661 type = make_aggr_type (TYPEOF_TYPE);
eb34af89 2662 TYPEOF_TYPE_EXPR (type) = expr;
b894fc05 2663
65a5559b 2664 return type;
b894fc05
JM
2665 }
2666
65a5559b
MM
2667 type = TREE_TYPE (expr);
2668
2669 if (!type || type == unknown_type_node)
2670 {
2671 error ("type of `%E' is unknown", expr);
2672 return error_mark_node;
2673 }
2674
2675 return type;
b894fc05 2676}
558475f0 2677
3eb24f73 2678/* Called from expand_body via walk_tree. Replace all AGGR_INIT_EXPRs
6de9cd9a 2679 with equivalent CALL_EXPRs. */
3eb24f73
MM
2680
2681static tree
3a978d72 2682simplify_aggr_init_exprs_r (tree* tp,
9eeb200f
JM
2683 int* walk_subtrees,
2684 void* data ATTRIBUTE_UNUSED)
3eb24f73 2685{
22e92ac3
MM
2686 /* We don't need to walk into types; there's nothing in a type that
2687 needs simplification. (And, furthermore, there are places we
2688 actively don't want to go. For example, we don't want to wander
2689 into the default arguments for a FUNCTION_DECL that appears in a
2690 CALL_EXPR.) */
9eeb200f 2691 if (TYPE_P (*tp))
22e92ac3
MM
2692 {
2693 *walk_subtrees = 0;
2694 return NULL_TREE;
2695 }
2696 /* Only AGGR_INIT_EXPRs are interesting. */
9eeb200f 2697 else if (TREE_CODE (*tp) != AGGR_INIT_EXPR)
3eb24f73
MM
2698 return NULL_TREE;
2699
9eeb200f
JM
2700 simplify_aggr_init_expr (tp);
2701
2702 /* Keep iterating. */
2703 return NULL_TREE;
2704}
2705
2706/* Replace the AGGR_INIT_EXPR at *TP with an equivalent CALL_EXPR. This
2707 function is broken out from the above for the benefit of the tree-ssa
2708 project. */
2709
2710void
2711simplify_aggr_init_expr (tree *tp)
2712{
2713 tree aggr_init_expr = *tp;
2714
3eb24f73 2715 /* Form an appropriate CALL_EXPR. */
9eeb200f
JM
2716 tree fn = TREE_OPERAND (aggr_init_expr, 0);
2717 tree args = TREE_OPERAND (aggr_init_expr, 1);
2718 tree slot = TREE_OPERAND (aggr_init_expr, 2);
2719 tree type = TREE_TYPE (aggr_init_expr);
2720
2721 tree call_expr;
2722 enum style_t { ctor, arg, pcc } style;
4977bab6 2723
3eb24f73 2724 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr))
4977bab6
ZW
2725 style = ctor;
2726#ifdef PCC_STATIC_STRUCT_RETURN
2727 else if (1)
2728 style = pcc;
2729#endif
2730 else if (TREE_ADDRESSABLE (type))
2731 style = arg;
2732 else
2733 /* We shouldn't build an AGGR_INIT_EXPR if we don't need any special
2734 handling. See build_cplus_new. */
2735 abort ();
2736
2737 if (style == ctor || style == arg)
3eb24f73 2738 {
4977bab6
ZW
2739 /* Pass the address of the slot. If this is a constructor, we
2740 replace the first argument; otherwise, we tack on a new one. */
9eeb200f
JM
2741 tree addr;
2742
4977bab6
ZW
2743 if (style == ctor)
2744 args = TREE_CHAIN (args);
2745
dffd7eb6 2746 cxx_mark_addressable (slot);
9eeb200f
JM
2747 addr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (slot)), slot);
2748 if (style == arg)
2749 {
2750 /* The return type might have different cv-quals from the slot. */
2751 tree fntype = TREE_TYPE (TREE_TYPE (fn));
2752#ifdef ENABLE_CHECKING
2753 if (TREE_CODE (fntype) != FUNCTION_TYPE
2754 && TREE_CODE (fntype) != METHOD_TYPE)
2755 abort ();
2756#endif
2757 addr = convert (build_pointer_type (TREE_TYPE (fntype)), addr);
2758 }
2759
2760 args = tree_cons (NULL_TREE, addr, args);
3eb24f73 2761 }
4977bab6 2762
b850de4f
MM
2763 call_expr = build (CALL_EXPR,
2764 TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))),
2765 fn, args, NULL_TREE);
3eb24f73 2766
4977bab6 2767 if (style == arg)
89ea02fb
JM
2768 /* Tell the backend that we've added our return slot to the argument
2769 list. */
2770 CALL_EXPR_HAS_RETURN_SLOT_ADDR (call_expr) = 1;
4977bab6 2771 else if (style == pcc)
3eb24f73 2772 {
4977bab6
ZW
2773 /* If we're using the non-reentrant PCC calling convention, then we
2774 need to copy the returned value out of the static buffer into the
2775 SLOT. */
78757caa 2776 push_deferring_access_checks (dk_no_check);
46af705a
JDA
2777 call_expr = build_aggr_init (slot, call_expr,
2778 DIRECT_BIND | LOOKUP_ONLYCONVERTING);
78757caa 2779 pop_deferring_access_checks ();
3eb24f73 2780 }
3eb24f73 2781
4977bab6
ZW
2782 /* We want to use the value of the initialized location as the
2783 result. */
325c3691 2784 call_expr = build (COMPOUND_EXPR, type, call_expr, slot);
3eb24f73 2785
3eb24f73 2786 *tp = call_expr;
3eb24f73
MM
2787}
2788
31f8e4f3
MM
2789/* Emit all thunks to FN that should be emitted when FN is emitted. */
2790
2791static void
3a978d72 2792emit_associated_thunks (tree fn)
31f8e4f3
MM
2793{
2794 /* When we use vcall offsets, we emit thunks with the virtual
2795 functions to which they thunk. The whole point of vcall offsets
2796 is so that you can know statically the entire set of thunks that
2797 will ever be needed for a given virtual function, thereby
2798 enabling you to output all the thunks with the function itself. */
3461fba7 2799 if (DECL_VIRTUAL_P (fn))
31f8e4f3 2800 {
bb5e8a7f 2801 tree thunk;
4977bab6 2802
bb5e8a7f 2803 for (thunk = DECL_THUNKS (fn); thunk; thunk = TREE_CHAIN (thunk))
4977bab6 2804 {
e00853fd 2805 if (!THUNK_ALIAS (thunk))
4977bab6 2806 {
bb885938
NS
2807 use_thunk (thunk, /*emit_p=*/1);
2808 if (DECL_RESULT_THUNK_P (thunk))
2809 {
2810 tree probe;
2811
2812 for (probe = DECL_THUNKS (thunk);
2813 probe; probe = TREE_CHAIN (probe))
2814 use_thunk (probe, /*emit_p=*/1);
2815 }
4977bab6 2816 }
bb885938
NS
2817 else
2818 my_friendly_assert (!DECL_THUNKS (thunk), 20031023);
4977bab6 2819 }
31f8e4f3
MM
2820 }
2821}
2822
558475f0
MM
2823/* Generate RTL for FN. */
2824
2825void
3a978d72 2826expand_body (tree fn)
558475f0 2827{
367aa585 2828 tree saved_function;
6de9cd9a 2829
92788413
MM
2830 /* Compute the appropriate object-file linkage for inline
2831 functions. */
79065db2 2832 if (DECL_DECLARED_INLINE_P (fn))
92788413
MM
2833 import_export_decl (fn);
2834
4f8e1232
MM
2835 /* If FN is external, then there's no point in generating RTL for
2836 it. This situation can arise with an inline function under
83662e2b 2837 `-fexternal-templates'; we instantiate the function, even though
4f8e1232
MM
2838 we're not planning on emitting it, in case we get a chance to
2839 inline it. */
2840 if (DECL_EXTERNAL (fn))
2841 return;
2842
4985cde3 2843 /* ??? When is this needed? */
367aa585 2844 saved_function = current_function_decl;
367aa585 2845
de81ffd4
JH
2846 /* Emit any thunks that should be emitted at the same time as FN. */
2847 emit_associated_thunks (fn);
2848
c1f927e8 2849 tree_rest_of_compilation (fn, function_depth > 1);
d658cd4c 2850
367aa585 2851 current_function_decl = saved_function;
ea11ca7e 2852
4985cde3 2853 extract_interface_info ();
14691f8d 2854
4985cde3
RH
2855 /* If this function is marked with the constructor attribute, add it
2856 to the list of functions to be called along with constructors
2857 from static duration objects. */
2858 if (DECL_STATIC_CONSTRUCTOR (fn))
2859 static_ctors = tree_cons (NULL_TREE, fn, static_ctors);
2860
2861 /* If this function is marked with the destructor attribute, add it
2862 to the list of functions to be called along with destructors from
2863 static duration objects. */
2864 if (DECL_STATIC_DESTRUCTOR (fn))
2865 static_dtors = tree_cons (NULL_TREE, fn, static_dtors);
85b22f78
NS
2866
2867 if (DECL_CLONED_FUNCTION_P (fn))
2868 {
2869 /* If this is a clone, go through the other clones now and mark
2870 their parameters used. We have to do that here, as we don't
2871 know whether any particular clone will be expanded, and
2872 therefore cannot pick one arbitrarily. */
2873 tree probe;
2874
2875 for (probe = TREE_CHAIN (DECL_CLONED_FUNCTION (fn));
2876 probe && DECL_CLONED_FUNCTION_P (probe);
2877 probe = TREE_CHAIN (probe))
2878 {
2879 tree parms;
2880
2881 for (parms = DECL_ARGUMENTS (probe);
2882 parms; parms = TREE_CHAIN (parms))
2883 TREE_USED (parms) = 1;
2884 }
2885 }
558475f0 2886}
54f7877c 2887
8cd2462c
JH
2888/* Generate RTL for FN. */
2889
2890void
5671bf27 2891expand_or_defer_fn (tree fn)
8cd2462c
JH
2892{
2893 /* When the parser calls us after finishing the body of a template
c353b8e3
MM
2894 function, we don't really want to expand the body. */
2895 if (processing_template_decl)
8cd2462c
JH
2896 {
2897 /* Normally, collection only occurs in rest_of_compilation. So,
2898 if we don't collect here, we never collect junk generated
2899 during the processing of templates until we hit a
2900 non-template function. */
2901 ggc_collect ();
2902 return;
2903 }
2904
2905 /* Replace AGGR_INIT_EXPRs with appropriate CALL_EXPRs. */
2906 walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),
2907 simplify_aggr_init_exprs_r,
2908 NULL);
2909
2910 /* If this is a constructor or destructor body, we have to clone
2911 it. */
2912 if (maybe_clone_body (fn))
2913 {
2914 /* We don't want to process FN again, so pretend we've written
2915 it out, even though we haven't. */
2916 TREE_ASM_WRITTEN (fn) = 1;
2917 return;
2918 }
2919
2920 /* There's no reason to do any of the work here if we're only doing
2921 semantic analysis; this code just generates RTL. */
2922 if (flag_syntax_only)
2923 return;
2924
e4d91027
RH
2925 /* Compute the appropriate object-file linkage for inline functions. */
2926 if (DECL_DECLARED_INLINE_P (fn))
2927 import_export_decl (fn);
8cd2462c 2928
99edd65d
RH
2929 function_depth++;
2930
e4d91027 2931 /* Expand or defer, at the whim of the compilation unit manager. */
6b00c969 2932 cgraph_finalize_function (fn, function_depth > 1);
99edd65d
RH
2933
2934 function_depth--;
8cd2462c
JH
2935}
2936
6de9cd9a
DN
2937struct nrv_data
2938{
2939 tree var;
2940 tree result;
2941 htab_t visited;
2942};
0d97bf4c 2943
6de9cd9a
DN
2944/* Helper function for walk_tree, used by finalize_nrv below. */
2945
2946static tree
2947finalize_nrv_r (tree* tp, int* walk_subtrees, void* data)
0d97bf4c 2948{
6de9cd9a
DN
2949 struct nrv_data *dp = (struct nrv_data *)data;
2950 void **slot;
07b2f2fd
JM
2951
2952 /* No need to walk into types. There wouldn't be any need to walk into
2953 non-statements, except that we have to consider STMT_EXPRs. */
0d97bf4c
JM
2954 if (TYPE_P (*tp))
2955 *walk_subtrees = 0;
6de9cd9a
DN
2956 /* Change all returns to just refer to the RESULT_DECL; this is a nop,
2957 but differs from using NULL_TREE in that it indicates that we care
2958 about the value of the RESULT_DECL. */
0d97bf4c 2959 else if (TREE_CODE (*tp) == RETURN_STMT)
6de9cd9a
DN
2960 RETURN_STMT_EXPR (*tp) = dp->result;
2961 /* Change all cleanups for the NRV to only run when an exception is
2962 thrown. */
07b2f2fd 2963 else if (TREE_CODE (*tp) == CLEANUP_STMT
6de9cd9a 2964 && CLEANUP_DECL (*tp) == dp->var)
659e5a7a 2965 CLEANUP_EH_ONLY (*tp) = 1;
6de9cd9a
DN
2966 /* Replace the DECL_STMT for the NRV with an initialization of the
2967 RESULT_DECL, if needed. */
2968 else if (TREE_CODE (*tp) == DECL_STMT
2969 && DECL_STMT_DECL (*tp) == dp->var)
2970 {
2971 tree init;
2972 if (DECL_INITIAL (dp->var)
2973 && DECL_INITIAL (dp->var) != error_mark_node)
2974 {
2975 init = build (INIT_EXPR, void_type_node, dp->result,
2976 DECL_INITIAL (dp->var));
2977 DECL_INITIAL (dp->var) = error_mark_node;
2978 }
2979 else
2980 init = NULL_TREE;
2981 init = build_stmt (EXPR_STMT, init);
2982 SET_EXPR_LOCUS (init, EXPR_LOCUS (*tp));
2983 TREE_CHAIN (init) = TREE_CHAIN (*tp);
2984 *tp = init;
2985 }
2986 /* And replace all uses of the NRV with the RESULT_DECL. */
2987 else if (*tp == dp->var)
2988 *tp = dp->result;
2989
2990 /* Avoid walking into the same tree more than once. Unfortunately, we
2991 can't just use walk_tree_without duplicates because it would only call
2992 us for the first occurrence of dp->var in the function body. */
2993 slot = htab_find_slot (dp->visited, *tp, INSERT);
2994 if (*slot)
2995 *walk_subtrees = 0;
2996 else
2997 *slot = *tp;
0d97bf4c
JM
2998
2999 /* Keep iterating. */
3000 return NULL_TREE;
3001}
3002
6de9cd9a
DN
3003/* Called from finish_function to implement the named return value
3004 optimization by overriding all the RETURN_STMTs and pertinent
3005 CLEANUP_STMTs and replacing all occurrences of VAR with RESULT, the
3006 RESULT_DECL for the function. */
f444e36b 3007
4985cde3 3008void
6de9cd9a 3009finalize_nrv (tree *tp, tree var, tree result)
f444e36b 3010{
6de9cd9a
DN
3011 struct nrv_data data;
3012
3013 /* Copy debugging information from VAR to RESULT. */
3014 DECL_NAME (result) = DECL_NAME (var);
3015 DECL_SOURCE_LOCATION (result) = DECL_SOURCE_LOCATION (var);
3016 DECL_ABSTRACT_ORIGIN (result) = DECL_ABSTRACT_ORIGIN (var);
3017 /* Don't forget that we take its address. */
3018 TREE_ADDRESSABLE (result) = TREE_ADDRESSABLE (var);
3019
3020 data.var = var;
3021 data.result = result;
3022 data.visited = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
3023 walk_tree (tp, finalize_nrv_r, &data, 0);
3024 htab_delete (data.visited);
b850de4f
MM
3025}
3026
54f7877c
MM
3027/* Perform initialization related to this module. */
3028
3029void
3a978d72 3030init_cp_semantics (void)
54f7877c 3031{
54f7877c 3032}
cf22909c
KL
3033
3034#include "gt-cp-semantics.h"