OSDN Git Service

Merge basic-improvements-branch to trunk
[pf3gnuchains/gcc-fork.git] / gcc / cp / typeck2.c
1 /* Report error messages, build initializers, and perform
2    some front-end optimizations for C++ compiler.
3    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4    1999, 2000, 2001, 2002 Free Software Foundation, Inc.
5    Hacked by Michael Tiemann (tiemann@cygnus.com)
6
7 This file is part of GNU CC.
8
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING.  If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.  */
23
24
25 /* This file is part of the C++ front end.
26    It contains routines to build C++ expressions given their operands,
27    including computing the types of the result, C and C++ specific error
28    checks, and some optimization.
29
30    There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
31    and to process initializations in declarations (since they work
32    like a strange sort of assignment).  */
33
34 #include "config.h"
35 #include "system.h"
36 #include "coretypes.h"
37 #include "tm.h"
38 #include "tree.h"
39 #include "cp-tree.h"
40 #include "flags.h"
41 #include "toplev.h"
42 #include "output.h"
43 #include "diagnostic.h"
44
45 static tree process_init_constructor PARAMS ((tree, tree, tree *));
46
47 /* Print an error message stemming from an attempt to use
48    BASETYPE as a base class for TYPE.  */
49
50 tree
51 error_not_base_type (basetype, type)
52      tree basetype, type;
53 {
54   if (TREE_CODE (basetype) == FUNCTION_DECL)
55     basetype = DECL_CONTEXT (basetype);
56   error ("type `%T' is not a base type for type `%T'", basetype, type);
57   return error_mark_node;
58 }
59
60 tree
61 binfo_or_else (base, type)
62      tree base, type;
63 {
64   tree binfo = lookup_base (type, base, ba_ignore, NULL);
65
66   if (binfo == error_mark_node)
67     return NULL_TREE;
68   else if (!binfo)
69     error_not_base_type (base, type);
70   return binfo;
71 }
72
73 /* According to ARM $7.1.6, "A `const' object may be initialized, but its
74    value may not be changed thereafter.  Thus, we emit hard errors for these,
75    rather than just pedwarns.  If `SOFT' is 1, then we just pedwarn.  (For
76    example, conversions to references.)  */
77
78 void
79 readonly_error (arg, string, soft)
80      tree arg;
81      const char *string;
82      int soft;
83 {
84   const char *fmt;
85   void (*fn) PARAMS ((const char *, ...));
86
87   if (soft)
88     fn = pedwarn;
89   else
90     fn = error;
91
92   if (TREE_CODE (arg) == COMPONENT_REF)
93     {
94       if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
95         fmt = "%s of data-member `%D' in read-only structure";
96       else
97         fmt = "%s of read-only data-member `%D'";
98       (*fn) (fmt, string, TREE_OPERAND (arg, 1));
99     }
100   else if (TREE_CODE (arg) == VAR_DECL)
101     {
102       if (DECL_LANG_SPECIFIC (arg)
103           && DECL_IN_AGGR_P (arg)
104           && !TREE_STATIC (arg))
105         fmt = "%s of constant field `%D'";
106       else
107         fmt = "%s of read-only variable `%D'";
108       (*fn) (fmt, string, arg);
109     }
110   else if (TREE_CODE (arg) == PARM_DECL)
111     (*fn) ("%s of read-only parameter `%D'", string, arg);
112   else if (TREE_CODE (arg) == INDIRECT_REF
113            && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE
114            && (TREE_CODE (TREE_OPERAND (arg, 0)) == VAR_DECL
115                || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
116     (*fn) ("%s of read-only reference `%D'", string, TREE_OPERAND (arg, 0));
117   else if (TREE_CODE (arg) == RESULT_DECL)
118     (*fn) ("%s of read-only named return value `%D'", string, arg);
119   else if (TREE_CODE (arg) == FUNCTION_DECL)
120     (*fn) ("%s of function `%D'", string, arg);
121   else
122     (*fn) ("%s of read-only location", string);
123 }
124
125 /* If TYPE has abstract virtual functions, issue an error about trying
126    to create an object of that type.  DECL is the object declared, or
127    NULL_TREE if the declaration is unavailable.  Returns 1 if an error
128    occurred; zero if all was well.  */
129
130 int
131 abstract_virtuals_error (decl, type)
132      tree decl;
133      tree type;
134 {
135   tree u;
136   tree tu;
137
138   if (!CLASS_TYPE_P (type) || !CLASSTYPE_PURE_VIRTUALS (type))
139     return 0;
140
141   if (!TYPE_SIZE (type))
142     /* TYPE is being defined, and during that time
143        CLASSTYPE_PURE_VIRTUALS holds the inline friends.  */
144     return 0;
145
146   u = CLASSTYPE_PURE_VIRTUALS (type);
147   if (decl)
148     {
149       if (TREE_CODE (decl) == RESULT_DECL)
150         return 0;
151
152       if (TREE_CODE (decl) == VAR_DECL)
153         error ("cannot declare variable `%D' to be of type `%T'",
154                     decl, type);
155       else if (TREE_CODE (decl) == PARM_DECL)
156         error ("cannot declare parameter `%D' to be of type `%T'",
157                     decl, type);
158       else if (TREE_CODE (decl) == FIELD_DECL)
159         error ("cannot declare field `%D' to be of type `%T'",
160                     decl, type);
161       else if (TREE_CODE (decl) == FUNCTION_DECL
162                && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
163         error ("invalid return type for member function `%#D'", decl);
164       else if (TREE_CODE (decl) == FUNCTION_DECL)
165         error ("invalid return type for function `%#D'", decl);
166     }
167   else
168     error ("cannot allocate an object of type `%T'", type);
169
170   /* Only go through this once.  */
171   if (TREE_PURPOSE (u) == NULL_TREE)
172     {
173       TREE_PURPOSE (u) = error_mark_node;
174
175       error ("  because the following virtual functions are abstract:");
176       for (tu = u; tu; tu = TREE_CHAIN (tu))
177         cp_error_at ("\t%#D", TREE_VALUE (tu));
178     }
179   else
180     error ("  since type `%T' has abstract virtual functions", type);
181
182   return 1;
183 }
184
185 /* Print an error message for invalid use of an incomplete type.
186    VALUE is the expression that was used (or 0 if that isn't known)
187    and TYPE is the type that was invalid.  DIAG_TYPE indicates the
188    type of diagnostic:  0 for an error, 1 for a warning, 2 for a
189    pedwarn.  */
190
191 void
192 cxx_incomplete_type_diagnostic (value, type, diag_type)
193      tree value;
194      tree type;
195      int diag_type;
196 {
197   int decl = 0;
198   void (*p_msg) PARAMS ((const char *, ...));
199   void (*p_msg_at) PARAMS ((const char *, ...));
200
201   if (diag_type == 1)
202     {
203       p_msg = warning;
204       p_msg_at = cp_warning_at;
205     }
206   else if (diag_type == 2)
207     {
208       p_msg = pedwarn;
209       p_msg_at = cp_pedwarn_at;
210     }
211   else
212     {
213       p_msg = error;
214       p_msg_at = cp_error_at;
215     }
216   
217   /* Avoid duplicate error message.  */
218   if (TREE_CODE (type) == ERROR_MARK)
219     return;
220
221   if (value != 0 && (TREE_CODE (value) == VAR_DECL
222                      || TREE_CODE (value) == PARM_DECL
223                      || TREE_CODE (value) == FIELD_DECL))
224     {
225       (*p_msg_at) ("`%D' has incomplete type", value);
226       decl = 1;
227     }
228 retry:
229   /* We must print an error message.  Be clever about what it says.  */
230
231   switch (TREE_CODE (type))
232     {
233     case RECORD_TYPE:
234     case UNION_TYPE:
235     case ENUMERAL_TYPE:
236       if (!decl)
237         (*p_msg) ("invalid use of undefined type `%#T'", type);
238       if (!TYPE_TEMPLATE_INFO (type))
239         (*p_msg_at) ("forward declaration of `%#T'", type);
240       else
241         (*p_msg_at) ("declaration of `%#T'", type);
242       break;
243
244     case VOID_TYPE:
245       (*p_msg) ("invalid use of `%T'", type);
246       break;
247
248     case ARRAY_TYPE:
249       if (TYPE_DOMAIN (type))
250         {
251           type = TREE_TYPE (type);
252           goto retry;
253         }
254       (*p_msg) ("invalid use of array with unspecified bounds");
255       break;
256
257     case OFFSET_TYPE:
258     bad_member:
259       (*p_msg) ("invalid use of member (did you forget the `&' ?)");
260       break;
261
262     case TEMPLATE_TYPE_PARM:
263       (*p_msg) ("invalid use of template type parameter");
264       break;
265
266     case UNKNOWN_TYPE:
267       if (value && TREE_CODE (value) == COMPONENT_REF)
268         goto bad_member;
269       else if (value && TREE_CODE (value) == ADDR_EXPR)
270         (*p_msg) ("address of overloaded function with no contextual type information");
271       else if (value && TREE_CODE (value) == OVERLOAD)
272         (*p_msg) ("overloaded function with no contextual type information");
273       else
274         (*p_msg) ("insufficient contextual information to determine type");
275       break;
276     
277     default:
278       abort ();
279     }
280 }
281
282 /* Backward-compatibility interface to incomplete_type_diagnostic;
283    required by ../tree.c.  */
284 #undef cxx_incomplete_type_error
285 void
286 cxx_incomplete_type_error (value, type)
287      tree value;
288      tree type;
289 {
290   cxx_incomplete_type_diagnostic (value, type, 0);
291 }
292
293 \f
294 /* Perform appropriate conversions on the initial value of a variable,
295    store it in the declaration DECL,
296    and print any error messages that are appropriate.
297    If the init is invalid, store an ERROR_MARK.
298
299    C++: Note that INIT might be a TREE_LIST, which would mean that it is
300    a base class initializer for some aggregate type, hopefully compatible
301    with DECL.  If INIT is a single element, and DECL is an aggregate
302    type, we silently convert INIT into a TREE_LIST, allowing a constructor
303    to be called.
304
305    If INIT is a TREE_LIST and there is no constructor, turn INIT
306    into a CONSTRUCTOR and use standard initialization techniques.
307    Perhaps a warning should be generated?
308
309    Returns value of initializer if initialization could not be
310    performed for static variable.  In that case, caller must do
311    the storing.  */
312
313 tree
314 store_init_value (decl, init)
315      tree decl, init;
316 {
317   register tree value, type;
318
319   /* If variable's type was invalidly declared, just ignore it.  */
320
321   type = TREE_TYPE (decl);
322   if (TREE_CODE (type) == ERROR_MARK)
323     return NULL_TREE;
324
325   if (IS_AGGR_TYPE (type))
326     {
327       if (! TYPE_HAS_TRIVIAL_INIT_REF (type)
328           && TREE_CODE (init) != CONSTRUCTOR)
329         abort ();
330
331       if (TREE_CODE (init) == TREE_LIST)
332         {
333           error ("constructor syntax used, but no constructor declared for type `%T'", type);
334           init = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (init));
335         }
336     }
337   else if (TREE_CODE (init) == TREE_LIST
338            && TREE_TYPE (init) != unknown_type_node)
339     {
340       if (TREE_CODE (decl) == RESULT_DECL)
341         {
342           if (TREE_CHAIN (init))
343             {
344               warning ("comma expression used to initialize return value");
345               init = build_compound_expr (init);
346             }
347           else
348             init = TREE_VALUE (init);
349         }
350       else if (TREE_CODE (init) == TREE_LIST
351                && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
352         {
353           error ("cannot initialize arrays using this syntax");
354           return NULL_TREE;
355         }
356       else
357         {
358           /* We get here with code like `int a (2);' */
359              
360           if (TREE_CHAIN (init) != NULL_TREE)
361             {
362               pedwarn ("initializer list being treated as compound expression");
363               init = build_compound_expr (init);
364             }
365           else
366             init = TREE_VALUE (init);
367         }
368     }
369
370   /* End of special C++ code.  */
371
372   /* Digest the specified initializer into an expression.  */
373   value = digest_init (type, init, (tree *) 0);
374
375   /* Store the expression if valid; else report error.  */
376
377   if (TREE_CODE (value) == ERROR_MARK)
378     ;
379   /* Other code expects that initializers for objects of types that need
380      constructing never make it into DECL_INITIAL, and passes 'init' to
381      build_aggr_init without checking DECL_INITIAL.  So just return.  */
382   else if (TYPE_NEEDS_CONSTRUCTING (type))
383     return value;
384   else if (TREE_STATIC (decl)
385            && (! TREE_CONSTANT (value)
386                || ! initializer_constant_valid_p (value, TREE_TYPE (value))
387 #if 0
388                /* A STATIC PUBLIC int variable doesn't have to be
389                   run time inited when doing pic.  (mrs) */
390                /* Since ctors and dtors are the only things that can
391                   reference vtables, and they are always written down
392                   the vtable definition, we can leave the
393                   vtables in initialized data space.
394                   However, other initialized data cannot be initialized
395                   this way.  Instead a global file-level initializer
396                   must do the job.  */
397                || (flag_pic && !DECL_VIRTUAL_P (decl) && TREE_PUBLIC (decl))
398 #endif
399                ))
400
401     return value;
402 #if 0 /* No, that's C.  jason 9/19/94 */
403   else
404     {
405       if (pedantic && TREE_CODE (value) == CONSTRUCTOR)
406         {
407           if (! TREE_CONSTANT (value) || ! TREE_STATIC (value))
408             pedwarn ("ISO C++ forbids non-constant aggregate initializer expressions");
409         }
410     }
411 #endif
412   
413   /* Store the VALUE in DECL_INITIAL.  If we're building a
414      statement-tree we will actually expand the initialization later
415      when we output this function.  */
416   DECL_INITIAL (decl) = value;
417   return NULL_TREE;
418 }
419
420 \f
421 /* Digest the parser output INIT as an initializer for type TYPE.
422    Return a C expression of type TYPE to represent the initial value.
423
424    If TAIL is nonzero, it points to a variable holding a list of elements
425    of which INIT is the first.  We update the list stored there by
426    removing from the head all the elements that we use.
427    Normally this is only one; we use more than one element only if
428    TYPE is an aggregate and INIT is not a constructor.  */
429
430 tree
431 digest_init (type, init, tail)
432      tree type, init, *tail;
433 {
434   enum tree_code code = TREE_CODE (type);
435   tree element = NULL_TREE;
436   tree old_tail_contents = NULL_TREE;
437   /* Nonzero if INIT is a braced grouping.  */
438   int raw_constructor;
439
440   /* By default, assume we use one element from a list.
441      We correct this later in the sole case where it is not true.  */
442
443   if (tail)
444     {
445       old_tail_contents = *tail;
446       *tail = TREE_CHAIN (*tail);
447     }
448
449   if (init == error_mark_node || (TREE_CODE (init) == TREE_LIST
450                                   && TREE_VALUE (init) == error_mark_node))
451     return error_mark_node;
452
453   if (TREE_CODE (init) == ERROR_MARK)
454     /* __PRETTY_FUNCTION__'s initializer is a bogus expression inside
455        a template function. This gets substituted during instantiation.  */
456     return init;
457
458   /* We must strip the outermost array type when completing the type,
459      because the its bounds might be incomplete at the moment.  */
460   if (!complete_type_or_else (TREE_CODE (type) == ARRAY_TYPE
461                               ? TREE_TYPE (type) : type, NULL_TREE))
462     return error_mark_node;
463   
464   /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
465   if (TREE_CODE (init) == NON_LVALUE_EXPR)
466     init = TREE_OPERAND (init, 0);
467
468   raw_constructor = (TREE_CODE (init) == CONSTRUCTOR 
469                      && TREE_HAS_CONSTRUCTOR (init));
470
471   if (raw_constructor
472       && CONSTRUCTOR_ELTS (init) != 0
473       && TREE_CHAIN (CONSTRUCTOR_ELTS (init)) == 0)
474     {
475       element = TREE_VALUE (CONSTRUCTOR_ELTS (init));
476       /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
477       if (element && TREE_CODE (element) == NON_LVALUE_EXPR)
478         element = TREE_OPERAND (element, 0);
479       if (element == error_mark_node)
480         return element;
481     }
482
483   /* Initialization of an array of chars from a string constant
484      optionally enclosed in braces.  */
485
486   if (code == ARRAY_TYPE)
487     {
488       tree typ1;
489
490       if (TREE_CODE (init) == TREE_LIST)
491         {
492           error ("initializing array with parameter list");
493           return error_mark_node;
494         }
495
496       typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
497       if (char_type_p (typ1)
498           && ((init && TREE_CODE (init) == STRING_CST)
499               || (element && TREE_CODE (element) == STRING_CST)))
500         {
501           tree string = element ? element : init;
502
503           if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
504                != char_type_node)
505               && TYPE_PRECISION (typ1) == BITS_PER_UNIT)
506             {
507               error ("char-array initialized from wide string");
508               return error_mark_node;
509             }
510           if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
511                == char_type_node)
512               && TYPE_PRECISION (typ1) != BITS_PER_UNIT)
513             {
514               error ("int-array initialized from non-wide string");
515               return error_mark_node;
516             }
517
518           TREE_TYPE (string) = type;
519           if (TYPE_DOMAIN (type) != 0
520               && TREE_CONSTANT (TYPE_SIZE (type)))
521             {
522               register int size
523                 = TREE_INT_CST_LOW (TYPE_SIZE (type));
524               size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
525               /* In C it is ok to subtract 1 from the length of the string
526                  because it's ok to ignore the terminating null char that is
527                  counted in the length of the constant, but in C++ this would
528                  be invalid.  */
529               if (size < TREE_STRING_LENGTH (string))
530                 pedwarn ("initializer-string for array of chars is too long");
531             }
532           return string;
533         }
534     }
535
536   /* Handle scalar types, including conversions,
537      and signature pointers and references.  */
538
539   if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
540       || code == ENUMERAL_TYPE || code == REFERENCE_TYPE
541       || code == BOOLEAN_TYPE || code == COMPLEX_TYPE
542       || TYPE_PTRMEMFUNC_P (type))
543     {
544       if (raw_constructor)
545         {
546           if (element == 0)
547             {
548               error ("initializer for scalar variable requires one element");
549               return error_mark_node;
550             }
551           init = element;
552         }
553       while (TREE_CODE (init) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (init))
554         {
555           pedwarn ("braces around scalar initializer for `%T'", type);
556           init = CONSTRUCTOR_ELTS (init);
557           if (TREE_CHAIN (init))
558             pedwarn ("ignoring extra initializers for `%T'", type);
559           init = TREE_VALUE (init);
560         }
561
562       return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
563                                          "initialization", NULL_TREE, 0);
564     }
565
566   /* Come here only for records and arrays (and unions with constructors).  */
567
568   if (COMPLETE_TYPE_P (type) && ! TREE_CONSTANT (TYPE_SIZE (type)))
569     {
570       error ("variable-sized object of type `%T' may not be initialized",
571                 type);
572       return error_mark_node;
573     }
574
575   if (code == ARRAY_TYPE || code == VECTOR_TYPE || IS_AGGR_TYPE_CODE (code))
576     {
577       if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type)
578           && TREE_HAS_CONSTRUCTOR (init))
579         {
580           error ("subobject of type `%T' must be initialized by constructor, not by `%E'",
581                     type, init);
582           return error_mark_node;
583         }
584       else if (raw_constructor)
585         return process_init_constructor (type, init, (tree *)0);
586       else if (can_convert_arg (type, TREE_TYPE (init), init)
587                || TYPE_NON_AGGREGATE_CLASS (type))
588         /* These are never initialized from multiple constructor elements.  */;
589       else if (tail != 0)
590         {
591           *tail = old_tail_contents;
592           return process_init_constructor (type, 0, tail);
593         }
594
595       if (code != ARRAY_TYPE)
596         {
597           int flags = LOOKUP_NORMAL;
598           /* Initialization from { } is copy-initialization.  */
599           if (tail)
600             flags |= LOOKUP_ONLYCONVERTING;
601
602           return convert_for_initialization (NULL_TREE, type, init, flags,
603                                              "initialization", NULL_TREE, 0);
604         }
605     }
606
607   error ("invalid initializer");
608   return error_mark_node;
609 }
610 \f
611 /* Process a constructor for a variable of type TYPE.
612    The constructor elements may be specified either with INIT or with ELTS,
613    only one of which should be non-null.
614
615    If INIT is specified, it is a CONSTRUCTOR node which is specifically
616    and solely for initializing this datum.
617
618    If ELTS is specified, it is the address of a variable containing
619    a list of expressions.  We take as many elements as we need
620    from the head of the list and update the list.
621
622    In the resulting constructor, TREE_CONSTANT is set if all elts are
623    constant, and TREE_STATIC is set if, in addition, all elts are simple enough
624    constants that the assembler and linker can compute them.  */
625
626 static tree
627 process_init_constructor (type, init, elts)
628      tree type, init, *elts;
629 {
630   register tree tail;
631   /* List of the elements of the result constructor,
632      in reverse order.  */
633   register tree members = NULL;
634   register tree next1;
635   tree result;
636   int allconstant = 1;
637   int allsimple = 1;
638   int erroneous = 0;
639
640   /* Make TAIL be the list of elements to use for the initialization,
641      no matter how the data was given to us.  */
642
643   if (elts)
644     {
645       if (warn_missing_braces)
646         warning ("aggregate has a partly bracketed initializer");
647       tail = *elts;
648     }
649   else
650     tail = CONSTRUCTOR_ELTS (init);
651
652   /* Gobble as many elements as needed, and make a constructor or initial value
653      for each element of this aggregate.  Chain them together in result.
654      If there are too few, use 0 for each scalar ultimate component.  */
655
656   if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == VECTOR_TYPE)
657     {
658       register long len;
659       register int i;
660
661       if (TREE_CODE (type) == ARRAY_TYPE)
662         {
663           tree domain = TYPE_DOMAIN (type);
664           if (domain)
665             len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
666                    - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
667                    + 1);
668           else
669             len = -1;  /* Take as many as there are */
670         }
671       else
672         {
673           /* Vectors are like simple fixed-size arrays.  */
674           len = TYPE_VECTOR_SUBPARTS (type);
675         }
676
677       for (i = 0; len < 0 || i < len; i++)
678         {
679           if (tail)
680             {
681               if (TREE_PURPOSE (tail)
682                   && (TREE_CODE (TREE_PURPOSE (tail)) != INTEGER_CST
683                       || compare_tree_int (TREE_PURPOSE (tail), i) != 0))
684                 sorry ("non-trivial labeled initializers");
685
686               if (TREE_VALUE (tail) != 0)
687                 {
688                   tree tail1 = tail;
689                   next1 = digest_init (TREE_TYPE (type),
690                                        TREE_VALUE (tail), &tail1);
691                   if (next1 == error_mark_node)
692                     return next1;
693                   my_friendly_assert
694                     (same_type_ignoring_top_level_qualifiers_p
695                      (TREE_TYPE (type), TREE_TYPE (next1)),
696                      981123);
697                   my_friendly_assert (tail1 == 0
698                                       || TREE_CODE (tail1) == TREE_LIST, 319);
699                   if (tail == tail1 && len < 0)
700                     {
701                       error ("non-empty initializer for array of empty elements");
702                       /* Just ignore what we were supposed to use.  */
703                       tail1 = NULL_TREE;
704                     }
705                   tail = tail1;
706                 }
707               else
708                 {
709                   next1 = error_mark_node;
710                   tail = TREE_CHAIN (tail);
711                 }
712             }
713           else if (len < 0)
714             /* We're done.  */
715             break;
716           else if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (type)))
717             {
718               /* If this type needs constructors run for
719                  default-initialization, we can't rely on the backend to do it
720                  for us, so build up TARGET_EXPRs.  If the type in question is
721                  a class, just build one up; if it's an array, recurse.  */
722
723               if (IS_AGGR_TYPE (TREE_TYPE (type)))
724                 next1 = build_functional_cast (TREE_TYPE (type), NULL_TREE);
725               else
726                 next1 = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, NULL_TREE);
727               next1 = digest_init (TREE_TYPE (type), next1, 0);
728             }
729           else if (! zero_init_p (TREE_TYPE (type)))
730             next1 = build_zero_init (TREE_TYPE (type),
731                                      /*static_storage_p=*/false);
732           else
733             /* The default zero-initialization is fine for us; don't
734                add anything to the CONSTRUCTOR.  */
735             break;
736
737           if (next1 == error_mark_node)
738             erroneous = 1;
739           else if (!TREE_CONSTANT (next1))
740             allconstant = 0;
741           else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
742             allsimple = 0;
743           members = tree_cons (size_int (i), next1, members);
744         }
745     }
746   else if (TREE_CODE (type) == RECORD_TYPE)
747     {
748       register tree field;
749
750       if (tail)
751         {
752           if (TYPE_USES_VIRTUAL_BASECLASSES (type))
753             {
754               sorry ("initializer list for object of class with virtual base classes");
755               return error_mark_node;
756             }
757
758           if (TYPE_BINFO_BASETYPES (type))
759             {
760               sorry ("initializer list for object of class with base classes");
761               return error_mark_node;
762             }
763
764           if (TYPE_POLYMORPHIC_P (type))
765             {
766               sorry ("initializer list for object using virtual functions");
767               return error_mark_node;
768             }
769         }
770
771       for (field = TYPE_FIELDS (type); field;
772            field = TREE_CHAIN (field))
773         {
774           if (! DECL_NAME (field) && DECL_C_BIT_FIELD (field))
775             {
776               members = tree_cons (field, integer_zero_node, members);
777               continue;
778             }
779
780           if (TREE_CODE (field) != FIELD_DECL || DECL_ARTIFICIAL (field))
781             continue;
782
783           if (tail)
784             {
785               if (TREE_PURPOSE (tail)
786                   && TREE_PURPOSE (tail) != field
787                   && TREE_PURPOSE (tail) != DECL_NAME (field))
788                 sorry ("non-trivial labeled initializers");
789
790               if (TREE_VALUE (tail) != 0)
791                 {
792                   tree tail1 = tail;
793
794                   next1 = digest_init (TREE_TYPE (field),
795                                        TREE_VALUE (tail), &tail1);
796                   my_friendly_assert (tail1 == 0
797                                       || TREE_CODE (tail1) == TREE_LIST, 320);
798                   tail = tail1;
799                 }
800               else
801                 {
802                   next1 = error_mark_node;
803                   tail = TREE_CHAIN (tail);
804                 }
805             }
806           else if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (field)))
807             {
808               /* If this type needs constructors run for
809                  default-initialization, we can't rely on the backend to do it
810                  for us, so build up TARGET_EXPRs.  If the type in question is
811                  a class, just build one up; if it's an array, recurse.  */
812
813               if (IS_AGGR_TYPE (TREE_TYPE (field)))
814                 next1 = build_functional_cast (TREE_TYPE (field),
815                                                NULL_TREE);
816               else
817                 {
818                   next1 = build (CONSTRUCTOR, NULL_TREE, NULL_TREE,
819                                  NULL_TREE);
820                   if (init)
821                     TREE_HAS_CONSTRUCTOR (next1)
822                        = TREE_HAS_CONSTRUCTOR (init);
823                 }
824               next1 = digest_init (TREE_TYPE (field), next1, 0);
825
826               /* Warn when some struct elements are implicitly initialized.  */
827               if (extra_warnings
828                   && (!init || TREE_HAS_CONSTRUCTOR (init)))
829                 warning ("missing initializer for member `%D'", field);
830             }
831           else
832             {
833               if (TREE_READONLY (field))
834                 error ("uninitialized const member `%D'", field);
835               else if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
836                 error ("member `%D' with uninitialized const fields",
837                           field);
838               else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
839                 error ("member `%D' is uninitialized reference", field);
840
841               /* Warn when some struct elements are implicitly initialized
842                  to zero.  */
843               if (extra_warnings
844                   && (!init || TREE_HAS_CONSTRUCTOR (init)))
845                 warning ("missing initializer for member `%D'", field);
846
847               if (! zero_init_p (TREE_TYPE (field)))
848                 next1 = build_zero_init (TREE_TYPE (field),
849                                          /*static_storage_p=*/false);
850               else
851                 /* The default zero-initialization is fine for us; don't
852                    add anything to the CONSTRUCTOR.  */
853                 continue;
854             }
855
856           if (next1 == error_mark_node)
857             erroneous = 1;
858           else if (!TREE_CONSTANT (next1))
859             allconstant = 0;
860           else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
861             allsimple = 0;
862           members = tree_cons (field, next1, members);
863         }
864     }
865   else if (TREE_CODE (type) == UNION_TYPE
866            /* If the initializer was empty, use default zero initialization.  */
867            && tail)
868     {
869       register tree field = TYPE_FIELDS (type);
870
871       /* Find the first named field.  ANSI decided in September 1990
872          that only named fields count here.  */
873       while (field && (!DECL_NAME (field) || TREE_CODE (field) != FIELD_DECL))
874         field = TREE_CHAIN (field);
875
876       /* If this element specifies a field, initialize via that field.  */
877       if (TREE_PURPOSE (tail) != NULL_TREE)
878         {
879           int win = 0;
880
881           if (TREE_CODE (TREE_PURPOSE (tail)) == FIELD_DECL)
882             /* Handle the case of a call by build_c_cast.  */
883             field = TREE_PURPOSE (tail), win = 1;
884           else if (TREE_CODE (TREE_PURPOSE (tail)) != IDENTIFIER_NODE)
885             error ("index value instead of field name in union initializer");
886           else
887             {
888               tree temp;
889               for (temp = TYPE_FIELDS (type);
890                    temp;
891                    temp = TREE_CHAIN (temp))
892                 if (DECL_NAME (temp) == TREE_PURPOSE (tail))
893                   break;
894               if (temp)
895                 field = temp, win = 1;
896               else
897                 error ("no field `%D' in union being initialized",
898                           TREE_PURPOSE (tail));
899             }
900           if (!win)
901             TREE_VALUE (tail) = error_mark_node;
902         }
903       else if (field == 0)
904         {
905           error ("union `%T' with no named members cannot be initialized",
906                     type);
907           TREE_VALUE (tail) = error_mark_node;
908         }
909
910       if (TREE_VALUE (tail) != 0)
911         {
912           tree tail1 = tail;
913
914           next1 = digest_init (TREE_TYPE (field),
915                                TREE_VALUE (tail), &tail1);
916           if (tail1 != 0 && TREE_CODE (tail1) != TREE_LIST)
917             abort ();
918           tail = tail1;
919         }
920       else
921         {
922           next1 = error_mark_node;
923           tail = TREE_CHAIN (tail);
924         }
925
926       if (next1 == error_mark_node)
927         erroneous = 1;
928       else if (!TREE_CONSTANT (next1))
929         allconstant = 0;
930       else if (initializer_constant_valid_p (next1, TREE_TYPE (next1)) == 0)
931         allsimple = 0;
932       members = tree_cons (field, next1, members);
933     }
934
935   /* If arguments were specified as a list, just remove the ones we used.  */
936   if (elts)
937     *elts = tail;
938   /* If arguments were specified as a constructor,
939      complain unless we used all the elements of the constructor.  */
940   else if (tail)
941     pedwarn ("excess elements in aggregate initializer");
942
943   if (erroneous)
944     return error_mark_node;
945
946   result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (members));
947   if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == NULL_TREE)
948     complete_array_type (type, result, /*do_default=*/0);
949   if (init)
950     TREE_HAS_CONSTRUCTOR (result) = TREE_HAS_CONSTRUCTOR (init);
951   if (allconstant) TREE_CONSTANT (result) = 1;
952   if (allconstant && allsimple) TREE_STATIC (result) = 1;
953   return result;
954 }
955 \f
956 /* Given a structure or union value DATUM, construct and return
957    the structure or union component which results from narrowing
958    that value to the base specified in BASETYPE.  For example, given the
959    hierarchy
960
961    class L { int ii; };
962    class A : L { ... };
963    class B : L { ... };
964    class C : A, B { ... };
965
966    and the declaration
967
968    C x;
969
970    then the expression
971
972    x.A::ii refers to the ii member of the L part of
973    the A part of the C object named by X.  In this case,
974    DATUM would be x, and BASETYPE would be A.
975
976    I used to think that this was nonconformant, that the standard specified
977    that first we look up ii in A, then convert x to an L& and pull out the
978    ii part.  But in fact, it does say that we convert x to an A&; A here
979    is known as the "naming class".  (jason 2000-12-19)
980
981    BINFO_P points to a variable initialized either to NULL_TREE or to the
982    binfo for the specific base subobject we want to convert to.  */
983
984 tree
985 build_scoped_ref (datum, basetype, binfo_p)
986      tree datum;
987      tree basetype;
988      tree *binfo_p;
989 {
990   tree binfo;
991
992   if (datum == error_mark_node)
993     return error_mark_node;
994   if (*binfo_p)
995     binfo = *binfo_p;
996   else
997     binfo = lookup_base (TREE_TYPE (datum), basetype, ba_check, NULL);
998
999   if (!binfo || binfo == error_mark_node)
1000     {
1001       *binfo_p = NULL_TREE;
1002       if (!binfo)
1003         error_not_base_type (basetype, TREE_TYPE (datum));
1004       return error_mark_node;
1005     }
1006
1007   *binfo_p = binfo;
1008   return build_base_path (PLUS_EXPR, datum, binfo, 1);
1009 }
1010
1011 /* Build a reference to an object specified by the C++ `->' operator.
1012    Usually this just involves dereferencing the object, but if the
1013    `->' operator is overloaded, then such overloads must be
1014    performed until an object which does not have the `->' operator
1015    overloaded is found.  An error is reported when circular pointer
1016    delegation is detected.  */
1017
1018 tree
1019 build_x_arrow (datum)
1020      tree datum;
1021 {
1022   tree types_memoized = NULL_TREE;
1023   register tree rval = datum;
1024   tree type = TREE_TYPE (rval);
1025   tree last_rval = NULL_TREE;
1026
1027   if (type == error_mark_node)
1028     return error_mark_node;
1029
1030   if (processing_template_decl)
1031     return build_min_nt (ARROW_EXPR, rval);
1032
1033   if (TREE_CODE (rval) == OFFSET_REF)
1034     {
1035       rval = resolve_offset_ref (datum);
1036       type = TREE_TYPE (rval);
1037     }
1038
1039   if (TREE_CODE (type) == REFERENCE_TYPE)
1040     {
1041       rval = convert_from_reference (rval);
1042       type = TREE_TYPE (rval);
1043     }
1044
1045   if (IS_AGGR_TYPE (type))
1046     {
1047       while ((rval = build_opfncall (COMPONENT_REF, LOOKUP_NORMAL, rval,
1048                                      NULL_TREE, NULL_TREE)))
1049         {
1050           if (rval == error_mark_node)
1051             return error_mark_node;
1052
1053           if (value_member (TREE_TYPE (rval), types_memoized))
1054             {
1055               error ("circular pointer delegation detected");
1056               return error_mark_node;
1057             }
1058           else
1059             {
1060               types_memoized = tree_cons (NULL_TREE, TREE_TYPE (rval),
1061                                           types_memoized);
1062             }
1063           last_rval = rval;
1064         }     
1065
1066       if (last_rval == NULL_TREE)
1067         {
1068           error ("base operand of `->' has non-pointer type `%T'", type);
1069           return error_mark_node;
1070         }
1071
1072       if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE)
1073         last_rval = convert_from_reference (last_rval);
1074     }
1075   else
1076     last_rval = default_conversion (rval);
1077
1078   if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE)
1079     return build_indirect_ref (last_rval, NULL);
1080
1081   if (types_memoized)
1082     error ("result of `operator->()' yields non-pointer result");
1083   else
1084     error ("base operand of `->' is not a pointer");
1085   return error_mark_node;
1086 }
1087
1088 /* Make an expression to refer to the COMPONENT field of
1089    structure or union value DATUM.  COMPONENT is an arbitrary
1090    expression.  DATUM has not already been checked out to be of
1091    aggregate type.
1092
1093    For C++, COMPONENT may be a TREE_LIST.  This happens when we must
1094    return an object of member type to a method of the current class,
1095    but there is not yet enough typing information to know which one.
1096    As a special case, if there is only one method by that name,
1097    it is returned.  Otherwise we return an expression which other
1098    routines will have to know how to deal with later.  */
1099
1100 tree
1101 build_m_component_ref (datum, component)
1102      tree datum, component;
1103 {
1104   tree type;
1105   tree objtype;
1106   tree field_type;
1107   int type_quals;
1108   tree binfo;
1109
1110   if (processing_template_decl)
1111     return build_min_nt (DOTSTAR_EXPR, datum, component);
1112
1113   datum = decay_conversion (datum);
1114
1115   if (datum == error_mark_node || component == error_mark_node)
1116     return error_mark_node;
1117
1118   objtype = TYPE_MAIN_VARIANT (TREE_TYPE (datum));  
1119
1120   if (TYPE_PTRMEMFUNC_P (TREE_TYPE (component)))
1121     {
1122       type = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (component)));
1123       field_type = type;
1124     }
1125   else if (TYPE_PTRMEM_P (TREE_TYPE (component)))
1126     {
1127       type = TREE_TYPE (TREE_TYPE (component));
1128       field_type = TREE_TYPE (type);
1129       
1130       /* Compute the type of the field, as described in [expr.ref].  */
1131       type_quals = TYPE_UNQUALIFIED;
1132       if (TREE_CODE (field_type) == REFERENCE_TYPE)
1133         /* The standard says that the type of the result should be the
1134            type referred to by the reference.  But for now, at least,
1135            we do the conversion from reference type later.  */
1136         ;
1137       else
1138         {
1139           type_quals = (cp_type_quals (field_type)  
1140                         | cp_type_quals (TREE_TYPE (datum)));
1141
1142           /* There's no such thing as a mutable pointer-to-member, so
1143              things are not as complex as they are for references to
1144              non-static data members.  */
1145           field_type = cp_build_qualified_type (field_type, type_quals);
1146         }
1147     }
1148   else
1149     {
1150       error ("`%E' cannot be used as a member pointer, since it is of type `%T'", 
1151                 component, TREE_TYPE (component));
1152       return error_mark_node;
1153     }
1154
1155   if (! IS_AGGR_TYPE (objtype))
1156     {
1157       error ("cannot apply member pointer `%E' to `%E', which is of non-aggregate type `%T'",
1158                 component, datum, objtype);
1159       return error_mark_node;
1160     }
1161
1162   binfo = lookup_base (objtype, TYPE_METHOD_BASETYPE (type),
1163                        ba_check, NULL);
1164   if (!binfo)
1165     {
1166       error ("member type `%T::' incompatible with object type `%T'",
1167                 TYPE_METHOD_BASETYPE (type), objtype);
1168       return error_mark_node;
1169     }
1170   else if (binfo == error_mark_node)
1171     return error_mark_node;
1172
1173   component = build (OFFSET_REF, field_type, datum, component);
1174   if (TREE_CODE (type) == OFFSET_TYPE)
1175     component = resolve_offset_ref (component);
1176   return component;
1177 }
1178
1179 /* Return a tree node for the expression TYPENAME '(' PARMS ')'.  */
1180
1181 tree
1182 build_functional_cast (exp, parms)
1183      tree exp;
1184      tree parms;
1185 {
1186   /* This is either a call to a constructor,
1187      or a C cast in C++'s `functional' notation.  */
1188   tree type;
1189
1190   if (exp == error_mark_node || parms == error_mark_node)
1191     return error_mark_node;
1192
1193   if (TREE_CODE (exp) == IDENTIFIER_NODE)
1194     {
1195       if (IDENTIFIER_HAS_TYPE_VALUE (exp))
1196         /* Either an enum or an aggregate type.  */
1197         type = IDENTIFIER_TYPE_VALUE (exp);
1198       else
1199         {
1200           type = lookup_name (exp, 1);
1201           if (!type || TREE_CODE (type) != TYPE_DECL)
1202             {
1203               error ("`%T' fails to be a typedef or built-in type", exp);
1204               return error_mark_node;
1205             }
1206           type = TREE_TYPE (type);
1207         }
1208     }
1209   else if (TREE_CODE (exp) == TYPE_DECL)
1210     type = TREE_TYPE (exp);
1211   else
1212     type = exp;
1213
1214   if (processing_template_decl)
1215     return build_min (CAST_EXPR, type, parms);
1216
1217   if (! IS_AGGR_TYPE (type))
1218     {
1219       /* this must build a C cast */
1220       if (parms == NULL_TREE)
1221         parms = integer_zero_node;
1222       else
1223         {
1224           if (TREE_CHAIN (parms) != NULL_TREE)
1225             pedwarn ("initializer list being treated as compound expression");
1226           parms = build_compound_expr (parms);
1227         }
1228
1229       return build_c_cast (type, parms);
1230     }
1231
1232   /* Prepare to evaluate as a call to a constructor.  If this expression
1233      is actually used, for example,
1234          
1235      return X (arg1, arg2, ...);
1236          
1237      then the slot being initialized will be filled in.  */
1238
1239   if (!complete_type_or_else (type, NULL_TREE))
1240     return error_mark_node;
1241   if (abstract_virtuals_error (NULL_TREE, type))
1242     return error_mark_node;
1243
1244   if (parms && TREE_CHAIN (parms) == NULL_TREE)
1245     return build_c_cast (type, TREE_VALUE (parms));
1246
1247   /* We need to zero-initialize POD types.  Let's do that for everything
1248      that doesn't need a constructor.  */
1249   if (parms == NULL_TREE && !TYPE_NEEDS_CONSTRUCTING (type)
1250       && TYPE_HAS_DEFAULT_CONSTRUCTOR (type))
1251     {
1252       exp = build (CONSTRUCTOR, type, NULL_TREE, NULL_TREE);
1253       return get_target_expr (exp);
1254     }
1255
1256   exp = build_special_member_call (NULL_TREE, complete_ctor_identifier, parms,
1257                                    TYPE_BINFO (type), LOOKUP_NORMAL);
1258
1259   if (exp == error_mark_node)
1260     return error_mark_node;
1261
1262   return build_cplus_new (type, exp);
1263 }
1264 \f
1265
1266 /* Complain about defining new types in inappropriate places.  We give an
1267    exception for C-style casts, to accommodate GNU C stylings.  */
1268
1269 void
1270 check_for_new_type (string, inptree)
1271      const char *string;
1272      flagged_type_tree inptree;
1273 {
1274   if (inptree.new_type_flag
1275       && (pedantic || strcmp (string, "cast") != 0))
1276     pedwarn ("ISO C++ forbids defining types within %s", string);
1277 }
1278
1279 /* Add new exception specifier SPEC, to the LIST we currently have.
1280    If it's already in LIST then do nothing.
1281    Moan if it's bad and we're allowed to. COMPLAIN < 0 means we
1282    know what we're doing.  */
1283
1284 tree
1285 add_exception_specifier (list, spec, complain)
1286      tree list, spec;
1287      int complain;
1288 {
1289   int ok;
1290   tree core = spec;
1291   int is_ptr;
1292   int diag_type = -1; /* none */
1293   
1294   if (spec == error_mark_node)
1295     return list;
1296   
1297   my_friendly_assert (spec && (!list || TREE_VALUE (list)), 19990317);
1298   
1299   /* [except.spec] 1, type in an exception specifier shall not be
1300      incomplete, or pointer or ref to incomplete other than pointer
1301      to cv void.  */
1302   is_ptr = TREE_CODE (core) == POINTER_TYPE;
1303   if (is_ptr || TREE_CODE (core) == REFERENCE_TYPE)
1304     core = TREE_TYPE (core);
1305   if (complain < 0)
1306     ok = 1;
1307   else if (VOID_TYPE_P (core))
1308     ok = is_ptr;
1309   else if (TREE_CODE (core) == TEMPLATE_TYPE_PARM)
1310     ok = 1;
1311   else if (processing_template_decl)
1312     ok = 1;
1313   else
1314     {
1315       ok = 1;
1316       /* 15.4/1 says that types in an exception specifier must be complete,
1317          but it seems more reasonable to only require this on definitions
1318          and calls.  So just give a pedwarn at this point; we will give an
1319          error later if we hit one of those two cases.  */
1320       if (!COMPLETE_TYPE_P (complete_type (core)))
1321         diag_type = 2; /* pedwarn */
1322     }
1323
1324   if (ok)
1325     {
1326       tree probe;
1327       
1328       for (probe = list; probe; probe = TREE_CHAIN (probe))
1329         if (same_type_p (TREE_VALUE (probe), spec))
1330           break;
1331       if (!probe)
1332         list = tree_cons (NULL_TREE, spec, list);
1333     }
1334   else
1335     diag_type = 0; /* error */
1336     
1337   if (diag_type >= 0 && complain)
1338     cxx_incomplete_type_diagnostic (NULL_TREE, core, diag_type);
1339
1340   return list;
1341 }
1342
1343 /* Combine the two exceptions specifier lists LIST and ADD, and return
1344    their union.  */
1345
1346 tree
1347 merge_exception_specifiers (list, add)
1348      tree list, add;
1349 {
1350   if (!list || !add)
1351     return NULL_TREE;
1352   else if (!TREE_VALUE (list))
1353     return add;
1354   else if (!TREE_VALUE (add))
1355     return list;
1356   else
1357     {
1358       tree orig_list = list;
1359       
1360       for (; add; add = TREE_CHAIN (add))
1361         {
1362           tree spec = TREE_VALUE (add);
1363           tree probe;
1364           
1365           for (probe = orig_list; probe; probe = TREE_CHAIN (probe))
1366             if (same_type_p (TREE_VALUE (probe), spec))
1367               break;
1368           if (!probe)
1369             {
1370               spec = build_tree_list (NULL_TREE, spec);
1371               TREE_CHAIN (spec) = list;
1372               list = spec;
1373             }
1374         }
1375     }
1376   return list;
1377 }
1378
1379 /* Subroutine of build_call.  Ensure that each of the types in the
1380    exception specification is complete.  Technically, 15.4/1 says that
1381    they need to be complete when we see a declaration of the function,
1382    but we should be able to get away with only requiring this when the
1383    function is defined or called.  See also add_exception_specifier.  */
1384
1385 void
1386 require_complete_eh_spec_types (fntype, decl)
1387      tree fntype, decl;
1388 {
1389   tree raises;
1390   /* Don't complain about calls to op new.  */
1391   if (decl && DECL_ARTIFICIAL (decl))
1392     return;
1393   for (raises = TYPE_RAISES_EXCEPTIONS (fntype); raises;
1394        raises = TREE_CHAIN (raises))
1395     {
1396       tree type = TREE_VALUE (raises);
1397       if (type && !COMPLETE_TYPE_P (type))
1398         {
1399           if (decl)
1400             error
1401               ("call to function `%D' which throws incomplete type `%#T'",
1402                decl, type);
1403           else
1404             error ("call to function which throws incomplete type `%#T'",
1405                    decl);
1406         }
1407     }
1408 }