00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "config.h"
00036 #include "system.h"
00037 #include "intl.h"
00038 #include "tree.h"
00039 #include "tree-inline.h"
00040 #include "rtl.h"
00041 #include "flags.h"
00042 #include "function.h"
00043 #include "output.h"
00044 #include "expr.h"
00045 #include "c-tree.h"
00046 #include "toplev.h"
00047 #include "ggc.h"
00048 #include "tm_p.h"
00049 #include "cpplib.h"
00050 #include "target.h"
00051 #include "debug.h"
00052 #include "timevar.h"
00053 #include "c-common.h"
00054 #include "c-pragma.h"
00055 #include "libfuncs.h"
00056 #include "except.h"
00057 #ifdef SGI_MONGOOSE
00058
00059 #include "defaults.h"
00060 #include "real.h"
00061 #include "wfe_decl.h"
00062 extern ST * Create_ST_For_Tree (tree);
00063
00064 #include "wfe_stmt.h"
00065 #include "tree-inline.h"
00066 #include "wfe_dst.h"
00067 #endif
00068
00069
00070 enum decl_context
00071 { NORMAL,
00072 FUNCDEF,
00073 PARM,
00074 FIELD,
00075 BITFIELD,
00076 TYPENAME};
00077
00078 #ifdef SGI_MONGOOSE
00079
00080 int ggc_p = 1;
00081 #endif
00082
00083
00084
00085
00086
00087 tree pending_invalid_xref;
00088
00089 const char *pending_invalid_xref_file;
00090 int pending_invalid_xref_line;
00091
00092
00093
00094
00095
00096
00097
00098 static tree enum_next_value;
00099
00100
00101
00102 static int enum_overflow;
00103
00104
00105
00106
00107 static tree last_function_parms;
00108
00109
00110
00111
00112 static tree last_function_parm_tags;
00113
00114
00115
00116
00117
00118 static tree current_function_parms;
00119
00120
00121 static tree current_function_parm_tags;
00122
00123
00124
00125 static const char *current_function_prototype_file;
00126 static int current_function_prototype_line;
00127
00128
00129
00130 static GTY(()) struct stmt_tree_s c_stmt_tree;
00131
00132
00133
00134 static GTY(()) tree c_scope_stmt_stack;
00135
00136
00137
00138
00139
00140 static GTY(()) tree named_labels;
00141
00142
00143
00144 static GTY(()) tree shadowed_labels;
00145
00146
00147
00148
00149 int current_function_returns_value;
00150
00151
00152
00153
00154 int current_function_returns_null;
00155
00156
00157
00158
00159 int current_function_returns_abnormally;
00160
00161
00162
00163
00164 static int warn_about_return_type;
00165
00166
00167
00168 static int current_extern_inline;
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 struct binding_level GTY(())
00187 {
00188
00189
00190
00191 tree names;
00192
00193
00194
00195
00196
00197
00198
00199 tree tags;
00200
00201
00202
00203
00204
00205 tree shadowed;
00206
00207
00208
00209
00210 tree blocks;
00211
00212
00213
00214 tree this_block;
00215
00216
00217 struct binding_level *level_chain;
00218
00219
00220 char parm_flag;
00221
00222
00223 char tag_transparent;
00224
00225
00226
00227
00228
00229 char subblocks_tag_transparent;
00230
00231
00232 char keep;
00233
00234
00235 char keep_if_subblocks;
00236
00237
00238
00239 tree incomplete_list;
00240
00241
00242
00243
00244 tree parm_order;
00245 };
00246
00247 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
00248
00249
00250
00251 static GTY(()) struct binding_level *current_binding_level;
00252
00253
00254
00255 static GTY((deletable (""))) struct binding_level *free_binding_level;
00256
00257
00258
00259
00260
00261 static GTY(()) struct binding_level *global_binding_level;
00262
00263
00264
00265 static struct binding_level clear_binding_level
00266 = {NULL, NULL, NULL, NULL, NULL, NULL_BINDING_LEVEL, 0, 0, 0, 0, 0, NULL,
00267 NULL};
00268
00269
00270
00271 static int keep_next_level_flag;
00272
00273
00274
00275
00276 static int keep_next_if_subblocks;
00277
00278
00279
00280
00281
00282
00283
00284 static GTY(()) struct binding_level *label_level_chain;
00285
00286
00287
00288 tree static_ctors, static_dtors;
00289
00290
00291
00292 static struct binding_level * make_binding_level PARAMS ((void));
00293 static void pop_binding_level PARAMS ((struct binding_level **));
00294 static void clear_limbo_values PARAMS ((tree));
00295 static int duplicate_decls PARAMS ((tree, tree, int));
00296 static int redeclaration_error_message PARAMS ((tree, tree));
00297 static void storedecls PARAMS ((tree));
00298 static void storetags PARAMS ((tree));
00299 static tree lookup_tag PARAMS ((enum tree_code, tree,
00300 struct binding_level *, int));
00301 static tree lookup_tag_reverse PARAMS ((tree));
00302 static tree grokdeclarator PARAMS ((tree, tree, enum decl_context,
00303 int));
00304 static tree grokparms PARAMS ((tree, int));
00305 static void layout_array_type PARAMS ((tree));
00306 static tree c_make_fname_decl PARAMS ((tree, int));
00307 static void c_expand_body PARAMS ((tree, int, int));
00308 static void warn_if_shadowing PARAMS ((tree, tree));
00309 static bool flexible_array_type_p PARAMS ((tree));
00310 static int field_decl_cmp PARAMS ((const PTR, const PTR));
00311 static tree set_save_expr_context PARAMS ((tree *, int *, void *));
00312
00313
00314
00315
00316
00317
00318 enum deprecated_states {
00319 DEPRECATED_NORMAL,
00320 DEPRECATED_SUPPRESS
00321 };
00322
00323 static enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
00324
00325 void
00326 c_print_identifier (file, node, indent)
00327 FILE *file;
00328 tree node;
00329 int indent;
00330 {
00331 print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4);
00332 print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4);
00333 print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
00334 print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4);
00335 print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4);
00336 print_node (file, "limbo value", IDENTIFIER_LIMBO_VALUE (node), indent + 4);
00337 if (C_IS_RESERVED_WORD (node))
00338 {
00339 tree rid = ridpointers[C_RID_CODE (node)];
00340 indent_to (file, indent + 4);
00341 fprintf (file, "rid ");
00342 fprintf (file, HOST_PTR_PRINTF, (void *)rid);
00343 fprintf (file, " \"%s\"", IDENTIFIER_POINTER (rid));
00344 }
00345 }
00346
00347
00348
00349
00350 void
00351 c_finish_incomplete_decl (decl)
00352 tree decl;
00353 {
00354 if (TREE_CODE (decl) == VAR_DECL)
00355 {
00356 tree type = TREE_TYPE (decl);
00357 if (type != error_mark_node
00358 && TREE_CODE (type) == ARRAY_TYPE
00359 && ! DECL_EXTERNAL (decl)
00360 && TYPE_DOMAIN (type) == 0)
00361 {
00362 warning_with_decl (decl, "array `%s' assumed to have one element");
00363
00364 complete_array_type (type, NULL_TREE, 1);
00365
00366 layout_decl (decl, 0);
00367 }
00368 }
00369 }
00370
00371
00372
00373 static struct binding_level *
00374 make_binding_level ()
00375 {
00376 if (free_binding_level)
00377 {
00378 struct binding_level *result = free_binding_level;
00379 free_binding_level = result->level_chain;
00380 return result;
00381 }
00382 else
00383 return (struct binding_level *) ggc_alloc (sizeof (struct binding_level));
00384 }
00385
00386
00387
00388 static void
00389 pop_binding_level (lp)
00390 struct binding_level **lp;
00391 {
00392 struct binding_level *l = *lp;
00393 *lp = l->level_chain;
00394
00395 memset (l, 0, sizeof (struct binding_level));
00396 l->level_chain = free_binding_level;
00397 free_binding_level = l;
00398 }
00399
00400
00401
00402 int
00403 global_bindings_p ()
00404 {
00405 return current_binding_level == global_binding_level;
00406 }
00407
00408 void
00409 keep_next_level ()
00410 {
00411 keep_next_level_flag = 1;
00412 }
00413
00414
00415
00416 int
00417 kept_level_p ()
00418 {
00419 return ((current_binding_level->keep_if_subblocks
00420 && current_binding_level->blocks != 0)
00421 || current_binding_level->keep
00422 || current_binding_level->names != 0
00423 || (current_binding_level->tags != 0
00424 && !current_binding_level->tag_transparent));
00425 }
00426
00427
00428
00429
00430
00431
00432 void
00433 declare_parm_level (definition_flag)
00434 int definition_flag ATTRIBUTE_UNUSED;
00435 {
00436 current_binding_level->parm_flag = 1;
00437 }
00438
00439
00440
00441 int
00442 in_parm_level_p ()
00443 {
00444 return current_binding_level->parm_flag;
00445 }
00446
00447
00448
00449
00450
00451 void
00452 pushlevel (tag_transparent)
00453 int tag_transparent;
00454 {
00455 struct binding_level *newlevel = NULL_BINDING_LEVEL;
00456
00457
00458
00459
00460 if (current_binding_level == global_binding_level)
00461 {
00462 named_labels = 0;
00463 }
00464
00465 newlevel = make_binding_level ();
00466
00467
00468
00469
00470 *newlevel = clear_binding_level;
00471 newlevel->tag_transparent
00472 = (tag_transparent
00473 || (current_binding_level
00474 ? current_binding_level->subblocks_tag_transparent
00475 : 0));
00476 newlevel->level_chain = current_binding_level;
00477 current_binding_level = newlevel;
00478 newlevel->keep = keep_next_level_flag;
00479 keep_next_level_flag = 0;
00480 newlevel->keep_if_subblocks = keep_next_if_subblocks;
00481 keep_next_if_subblocks = 0;
00482 }
00483
00484
00485
00486 static void
00487 clear_limbo_values (block)
00488 tree block;
00489 {
00490 tree tem;
00491
00492 for (tem = BLOCK_VARS (block); tem; tem = TREE_CHAIN (tem))
00493 if (DECL_NAME (tem) != 0)
00494 IDENTIFIER_LIMBO_VALUE (DECL_NAME (tem)) = 0;
00495
00496 for (tem = BLOCK_SUBBLOCKS (block); tem; tem = TREE_CHAIN (tem))
00497 clear_limbo_values (tem);
00498 }
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515 tree
00516 poplevel (keep, reverse, functionbody)
00517 int keep;
00518 int reverse;
00519 int functionbody;
00520 {
00521 tree link;
00522
00523
00524 tree decls;
00525 tree tags = current_binding_level->tags;
00526 tree subblocks = current_binding_level->blocks;
00527 tree block = 0;
00528 tree decl;
00529 int block_previously_created;
00530
00531 keep |= current_binding_level->keep;
00532
00533
00534
00535 #if 0
00536
00537 for (link = tags; link; link = TREE_CHAIN (link))
00538 if (!COMPLETE_TYPE_P (TREE_VALUE (link)))
00539 {
00540 tree type = TREE_VALUE (link);
00541 tree type_name = TYPE_NAME (type);
00542 char *id = IDENTIFIER_POINTER (TREE_CODE (type_name) == IDENTIFIER_NODE
00543 ? type_name
00544 : DECL_NAME (type_name));
00545 switch (TREE_CODE (type))
00546 {
00547 case RECORD_TYPE:
00548 error ("`struct %s' incomplete in scope ending here", id);
00549 break;
00550 case UNION_TYPE:
00551 error ("`union %s' incomplete in scope ending here", id);
00552 break;
00553 case ENUMERAL_TYPE:
00554 error ("`enum %s' incomplete in scope ending here", id);
00555 break;
00556 }
00557 }
00558 #endif
00559
00560
00561
00562
00563
00564 if (reverse)
00565 current_binding_level->names
00566 = decls = nreverse (current_binding_level->names);
00567 else
00568 decls = current_binding_level->names;
00569
00570
00571
00572
00573 for (decl = decls; decl; decl = TREE_CHAIN (decl))
00574 if (TREE_CODE (decl) == FUNCTION_DECL
00575 && ! TREE_ASM_WRITTEN (decl)
00576 && DECL_INITIAL (decl) != 0
00577 && TREE_ADDRESSABLE (decl))
00578 {
00579
00580
00581
00582
00583
00584
00585 if (DECL_ABSTRACT_ORIGIN (decl) != 0
00586 && DECL_ABSTRACT_ORIGIN (decl) != decl)
00587 TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
00588 }
00589
00590
00591
00592
00593
00594 warn_about_unused_variables (getdecls ());
00595
00596
00597
00598
00599
00600 block = 0;
00601 block_previously_created = (current_binding_level->this_block != 0);
00602 if (block_previously_created)
00603 block = current_binding_level->this_block;
00604 else if (keep || functionbody
00605 || (current_binding_level->keep_if_subblocks && subblocks != 0))
00606 block = make_node (BLOCK);
00607 if (block != 0)
00608 {
00609 BLOCK_VARS (block) = decls;
00610 BLOCK_SUBBLOCKS (block) = subblocks;
00611 }
00612
00613
00614
00615 for (link = subblocks; link; link = TREE_CHAIN (link))
00616 BLOCK_SUPERCONTEXT (link) = block;
00617
00618
00619
00620 for (link = decls; link; link = TREE_CHAIN (link))
00621 {
00622 if (DECL_NAME (link) != 0)
00623 {
00624
00625
00626 if (DECL_EXTERNAL (link))
00627 {
00628 if (TREE_USED (link))
00629 TREE_USED (DECL_NAME (link)) = 1;
00630 if (TREE_ADDRESSABLE (link))
00631 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
00632 }
00633 IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = 0;
00634 }
00635 }
00636
00637
00638
00639
00640 for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
00641 IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
00642
00643
00644
00645
00646
00647 if (functionbody)
00648 {
00649 clear_limbo_values (block);
00650
00651
00652
00653
00654
00655
00656 BLOCK_VARS (block) = 0;
00657
00658
00659
00660
00661
00662 for (link = named_labels; link; link = TREE_CHAIN (link))
00663 {
00664 tree label = TREE_VALUE (link);
00665
00666 if (DECL_INITIAL (label) == 0)
00667 {
00668 error_with_decl (label, "label `%s' used but not defined");
00669
00670 define_label (input_filename, lineno,
00671 DECL_NAME (label));
00672 }
00673 else if (warn_unused_label && !TREE_USED (label))
00674 warning_with_decl (label, "label `%s' defined but not used");
00675 IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0;
00676
00677
00678
00679 TREE_CHAIN (label) = BLOCK_VARS (block);
00680 BLOCK_VARS (block) = label;
00681 }
00682 }
00683
00684
00685
00686 pop_binding_level (¤t_binding_level);
00687
00688
00689 if (functionbody)
00690 DECL_INITIAL (current_function_decl) = block;
00691 else if (block)
00692 {
00693 if (!block_previously_created)
00694 current_binding_level->blocks
00695 = chainon (current_binding_level->blocks, block);
00696 }
00697
00698
00699
00700
00701
00702 else if (subblocks)
00703 current_binding_level->blocks
00704 = chainon (current_binding_level->blocks, subblocks);
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720 if (functionbody)
00721 for (link = tags; link; link = TREE_CHAIN (link))
00722 TYPE_CONTEXT (TREE_VALUE (link)) = current_function_decl;
00723 else if (block)
00724 for (link = tags; link; link = TREE_CHAIN (link))
00725 TYPE_CONTEXT (TREE_VALUE (link)) = block;
00726
00727 if (block)
00728 TREE_USED (block) = 1;
00729
00730 return block;
00731 }
00732
00733
00734
00735
00736
00737 void
00738 insert_block (block)
00739 tree block;
00740 {
00741 TREE_USED (block) = 1;
00742 current_binding_level->blocks
00743 = chainon (current_binding_level->blocks, block);
00744 }
00745
00746
00747
00748
00749 void
00750 set_block (block)
00751 tree block;
00752 {
00753 current_binding_level->this_block = block;
00754 current_binding_level->names = chainon (current_binding_level->names,
00755 BLOCK_VARS (block));
00756 current_binding_level->blocks = chainon (current_binding_level->blocks,
00757 BLOCK_SUBBLOCKS (block));
00758 }
00759
00760 void
00761 push_label_level ()
00762 {
00763 struct binding_level *newlevel;
00764
00765 newlevel = make_binding_level ();
00766
00767
00768
00769 newlevel->level_chain = label_level_chain;
00770 label_level_chain = newlevel;
00771
00772 newlevel->names = named_labels;
00773 newlevel->shadowed = shadowed_labels;
00774 named_labels = 0;
00775 shadowed_labels = 0;
00776 }
00777
00778 void
00779 pop_label_level ()
00780 {
00781 struct binding_level *level = label_level_chain;
00782 tree link, prev;
00783
00784
00785
00786 for (link = named_labels, prev = 0; link;)
00787 {
00788 if (C_DECLARED_LABEL_FLAG (TREE_VALUE (link)))
00789 {
00790 if (DECL_SOURCE_LINE (TREE_VALUE (link)) == 0)
00791 {
00792 error_with_decl (TREE_VALUE (link),
00793 "label `%s' used but not defined");
00794
00795 define_label (input_filename, lineno,
00796 DECL_NAME (TREE_VALUE (link)));
00797 }
00798 else if (warn_unused_label && !TREE_USED (TREE_VALUE (link)))
00799 warning_with_decl (TREE_VALUE (link),
00800 "label `%s' defined but not used");
00801 IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link))) = 0;
00802
00803
00804 link = TREE_CHAIN (link);
00805 if (prev)
00806 TREE_CHAIN (prev) = link;
00807 else
00808 named_labels = link;
00809 }
00810 else
00811 {
00812 prev = link;
00813 link = TREE_CHAIN (link);
00814 }
00815 }
00816
00817
00818 for (link = shadowed_labels; link; link = TREE_CHAIN (link))
00819 if (DECL_NAME (TREE_VALUE (link)) != 0)
00820 IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)))
00821 = TREE_VALUE (link);
00822
00823 named_labels = chainon (named_labels, level->names);
00824 shadowed_labels = level->shadowed;
00825
00826
00827 pop_binding_level (&label_level_chain);
00828 }
00829
00830
00831
00832
00833
00834
00835
00836
00837 void
00838 pushtag (name, type)
00839 tree name, type;
00840 {
00841 struct binding_level *b;
00842
00843
00844
00845 for (b = current_binding_level; b->tag_transparent; b = b->level_chain)
00846 continue;
00847
00848 if (name)
00849 {
00850
00851
00852 if (TYPE_NAME (type) == 0)
00853 TYPE_NAME (type) = name;
00854 }
00855
00856 b->tags = tree_cons (name, type, b->tags);
00857
00858
00859
00860
00861
00862
00863
00864
00865 TYPE_STUB_DECL (type) = pushdecl (build_decl (TYPE_DECL, NULL_TREE, type));
00866
00867
00868
00869 TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type));
00870 }
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883 static int
00884 duplicate_decls (newdecl, olddecl, different_binding_level)
00885 tree newdecl, olddecl;
00886 int different_binding_level;
00887 {
00888 int types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl));
00889 int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
00890 && DECL_INITIAL (newdecl) != 0);
00891 tree oldtype = TREE_TYPE (olddecl);
00892 tree newtype = TREE_TYPE (newdecl);
00893 int errmsg = 0;
00894
00895 if (DECL_P (olddecl))
00896 {
00897 if (TREE_CODE (newdecl) == FUNCTION_DECL
00898 && TREE_CODE (olddecl) == FUNCTION_DECL
00899 && (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl)))
00900 {
00901 if (DECL_DECLARED_INLINE_P (newdecl)
00902 && DECL_UNINLINABLE (newdecl)
00903 && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
00904 ;
00905 else if (DECL_DECLARED_INLINE_P (olddecl)
00906 && DECL_UNINLINABLE (olddecl)
00907 && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
00908 ;
00909 else if (DECL_DECLARED_INLINE_P (newdecl)
00910 && ! DECL_DECLARED_INLINE_P (olddecl)
00911 && DECL_UNINLINABLE (olddecl)
00912 && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
00913 {
00914 warning_with_decl (newdecl,
00915 "function `%s' redeclared as inline");
00916 warning_with_decl (olddecl,
00917 "previous declaration of function `%s' with attribute noinline");
00918 }
00919 else if (DECL_DECLARED_INLINE_P (olddecl)
00920 && DECL_UNINLINABLE (newdecl)
00921 && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
00922 {
00923 warning_with_decl (newdecl,
00924 "function `%s' redeclared with attribute noinline");
00925 warning_with_decl (olddecl,
00926 "previous declaration of function `%s' was inline");
00927 }
00928 }
00929
00930 DECL_ATTRIBUTES (newdecl)
00931 = (*targetm.merge_decl_attributes) (olddecl, newdecl);
00932 }
00933
00934 if (TREE_CODE (newtype) == ERROR_MARK
00935 || TREE_CODE (oldtype) == ERROR_MARK)
00936 types_match = 0;
00937
00938
00939
00940
00941 if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
00942 {
00943 if (TREE_CODE (olddecl) == FUNCTION_DECL
00944 && (DECL_BUILT_IN (olddecl)
00945 || DECL_BUILT_IN_NONANSI (olddecl)))
00946 {
00947
00948
00949
00950 if (!TREE_PUBLIC (newdecl))
00951 {
00952 if (!warn_shadow)
00953 ;
00954 else if (DECL_BUILT_IN (olddecl))
00955 warning_with_decl (newdecl, "shadowing built-in function `%s'");
00956 else
00957 warning_with_decl (newdecl, "shadowing library function `%s'");
00958 }
00959
00960
00961 else if (! DECL_BUILT_IN (olddecl))
00962 warning_with_decl (newdecl,
00963 "library function `%s' declared as non-function");
00964
00965 else if (DECL_BUILT_IN_NONANSI (olddecl))
00966 warning_with_decl (newdecl,
00967 "built-in function `%s' declared as non-function");
00968 else
00969 warning_with_decl (newdecl,
00970 "built-in function `%s' declared as non-function");
00971 }
00972 else
00973 {
00974 error_with_decl (newdecl, "`%s' redeclared as different kind of symbol");
00975 error_with_decl (olddecl, "previous declaration of `%s'");
00976 }
00977
00978 return 0;
00979 }
00980
00981
00982
00983 if (types_match && TREE_CODE (newdecl) == PARM_DECL
00984 && TREE_ASM_WRITTEN (olddecl) && ! TREE_ASM_WRITTEN (newdecl))
00985 return 1;
00986
00987
00988
00989
00990
00991
00992 if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_BUILT_IN (olddecl))
00993 {
00994
00995 if (!TREE_PUBLIC (newdecl))
00996 {
00997
00998
00999
01000 if (warn_shadow)
01001 warning_with_decl (newdecl, "shadowing built-in function `%s'");
01002
01003 return 0;
01004 }
01005 else if (!types_match)
01006 {
01007
01008 tree oldreturntype = TREE_TYPE (oldtype);
01009 tree newreturntype = TREE_TYPE (newtype);
01010
01011 if (TYPE_MODE (oldreturntype) == TYPE_MODE (newreturntype))
01012 {
01013
01014
01015 tree trytype
01016 = build_function_type (newreturntype,
01017 TYPE_ARG_TYPES (oldtype));
01018 trytype = build_type_attribute_variant (trytype,
01019 TYPE_ATTRIBUTES (oldtype));
01020
01021 types_match = comptypes (newtype, trytype);
01022 if (types_match)
01023 oldtype = trytype;
01024 }
01025
01026
01027 if (TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != 0
01028 && TYPE_ARG_TYPES (oldtype) != 0
01029 && TREE_VALUE (TYPE_ARG_TYPES (newtype)) != 0
01030 && TREE_VALUE (TYPE_ARG_TYPES (oldtype)) != 0
01031 && (TYPE_MODE (TREE_VALUE (TYPE_ARG_TYPES (newtype)))
01032 == TYPE_MODE (TREE_VALUE (TYPE_ARG_TYPES (oldtype)))))
01033 {
01034
01035
01036 tree trytype
01037 = build_function_type (TREE_TYPE (oldtype),
01038 tree_cons (NULL_TREE,
01039 TREE_VALUE (TYPE_ARG_TYPES (newtype)),
01040 TREE_CHAIN (TYPE_ARG_TYPES (oldtype))));
01041 trytype = build_type_attribute_variant (trytype,
01042 TYPE_ATTRIBUTES (oldtype));
01043
01044 types_match = comptypes (newtype, trytype);
01045 if (types_match)
01046 oldtype = trytype;
01047 }
01048 if (! different_binding_level)
01049 TREE_TYPE (olddecl) = oldtype;
01050 }
01051 else if (TYPE_ARG_TYPES (oldtype) == NULL
01052 && TYPE_ARG_TYPES (newtype) != NULL)
01053 {
01054
01055
01056
01057 tree trytype
01058 = build_function_type (TREE_TYPE (oldtype),
01059 TYPE_ARG_TYPES (newtype));
01060 trytype = build_type_attribute_variant (trytype,
01061 TYPE_ATTRIBUTES (oldtype));
01062
01063 oldtype = trytype;
01064 if (! different_binding_level)
01065 TREE_TYPE (olddecl) = oldtype;
01066 }
01067 if (!types_match)
01068 {
01069
01070 warning_with_decl (newdecl, "conflicting types for built-in function `%s'");
01071 return 0;
01072 }
01073 }
01074 else if (TREE_CODE (olddecl) == FUNCTION_DECL
01075 && DECL_SOURCE_LINE (olddecl) == 0)
01076 {
01077
01078
01079 if (!TREE_PUBLIC (newdecl))
01080 {
01081
01082
01083 return 0;
01084 }
01085 else if (!types_match)
01086 {
01087
01088
01089
01090 TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
01091 }
01092 }
01093
01094
01095 else if (!types_match
01096 && TREE_CODE (olddecl) == FUNCTION_DECL
01097 && TREE_CODE (newdecl) == FUNCTION_DECL
01098 && TREE_CODE (TREE_TYPE (oldtype)) == POINTER_TYPE
01099 && TREE_CODE (TREE_TYPE (newtype)) == POINTER_TYPE
01100 && (DECL_IN_SYSTEM_HEADER (olddecl)
01101 || DECL_IN_SYSTEM_HEADER (newdecl))
01102 && ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (newtype))) == void_type_node
01103 && TYPE_ARG_TYPES (oldtype) == 0
01104 && self_promoting_args_p (TYPE_ARG_TYPES (newtype))
01105 && TREE_TYPE (TREE_TYPE (oldtype)) == char_type_node)
01106 ||
01107 (TREE_TYPE (TREE_TYPE (newtype)) == char_type_node
01108 && TYPE_ARG_TYPES (newtype) == 0
01109 && self_promoting_args_p (TYPE_ARG_TYPES (oldtype))
01110 && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node)))
01111 {
01112 if (pedantic)
01113 pedwarn_with_decl (newdecl, "conflicting types for `%s'");
01114
01115 if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node)
01116 TREE_TYPE (newdecl) = newtype = oldtype;
01117
01118
01119
01120 DECL_IN_SYSTEM_HEADER (newdecl) = 1;
01121 }
01122 else if (!types_match
01123
01124
01125 && ! (TREE_CODE (olddecl) == FUNCTION_DECL
01126 && ! pedantic
01127
01128 && comptypes (TREE_TYPE (oldtype),
01129 TREE_TYPE (newtype))
01130 && TYPE_ARG_TYPES (newtype) == 0))
01131 {
01132 error_with_decl (newdecl, "conflicting types for `%s'");
01133
01134
01135 if (TREE_CODE (olddecl) == FUNCTION_DECL
01136 && comptypes (TREE_TYPE (oldtype),
01137 TREE_TYPE (newtype))
01138 && ((TYPE_ARG_TYPES (oldtype) == 0
01139 && DECL_INITIAL (olddecl) == 0)
01140 ||
01141 (TYPE_ARG_TYPES (newtype) == 0
01142 && DECL_INITIAL (newdecl) == 0)))
01143 {
01144
01145 tree t = TYPE_ARG_TYPES (oldtype);
01146 if (t == 0)
01147 t = TYPE_ARG_TYPES (newtype);
01148 for (; t; t = TREE_CHAIN (t))
01149 {
01150 tree type = TREE_VALUE (t);
01151
01152 if (TREE_CHAIN (t) == 0
01153 && TYPE_MAIN_VARIANT (type) != void_type_node)
01154 {
01155 error ("a parameter list with an ellipsis can't match an empty parameter name list declaration");
01156 break;
01157 }
01158
01159 if (c_type_promotes_to (type) != type)
01160 {
01161 error ("an argument type that has a default promotion can't match an empty parameter name list declaration");
01162 break;
01163 }
01164 }
01165 }
01166 error_with_decl (olddecl, "previous declaration of `%s'");
01167
01168
01169
01170
01171
01172 if (TREE_CODE (newdecl) == VAR_DECL)
01173 DECL_INITIAL (newdecl) = 0;
01174 }
01175
01176 else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
01177 && !DECL_THREAD_LOCAL (olddecl) && DECL_THREAD_LOCAL (newdecl))
01178 {
01179 error_with_decl (newdecl, "thread-local declaration of `%s' follows non thread-local declaration");
01180 error_with_decl (olddecl, "previous declaration of `%s'");
01181 }
01182
01183 else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
01184 && DECL_THREAD_LOCAL (olddecl) && !DECL_THREAD_LOCAL (newdecl))
01185 {
01186 error_with_decl (newdecl, "non thread-local declaration of `%s' follows thread-local declaration");
01187 error_with_decl (olddecl, "previous declaration of `%s'");
01188 }
01189 else
01190 {
01191 errmsg = redeclaration_error_message (newdecl, olddecl);
01192 if (errmsg)
01193 {
01194 switch (errmsg)
01195 {
01196 case 1:
01197 error_with_decl (newdecl, "redefinition of `%s'");
01198 break;
01199 case 2:
01200 error_with_decl (newdecl, "redeclaration of `%s'");
01201 break;
01202 case 3:
01203 error_with_decl (newdecl, "conflicting declarations of `%s'");
01204 break;
01205 default:
01206 abort ();
01207 }
01208
01209 error_with_decl (olddecl,
01210 ((DECL_INITIAL (olddecl)
01211 && current_binding_level == global_binding_level)
01212 ? "`%s' previously defined here"
01213 : "`%s' previously declared here"));
01214 return 0;
01215 }
01216 else if (TREE_CODE (newdecl) == TYPE_DECL
01217 && (DECL_IN_SYSTEM_HEADER (olddecl)
01218 || DECL_IN_SYSTEM_HEADER (newdecl)))
01219 {
01220 warning_with_decl (newdecl, "redefinition of `%s'");
01221 warning_with_decl
01222 (olddecl,
01223 ((DECL_INITIAL (olddecl)
01224 && current_binding_level == global_binding_level)
01225 ? "`%s' previously defined here"
01226 : "`%s' previously declared here"));
01227 }
01228 else if (TREE_CODE (olddecl) == FUNCTION_DECL
01229 && DECL_INITIAL (olddecl) != 0
01230 && TYPE_ARG_TYPES (oldtype) == 0
01231 && TYPE_ARG_TYPES (newtype) != 0
01232 && TYPE_ACTUAL_ARG_TYPES (oldtype) != 0)
01233 {
01234 tree type, parm;
01235 int nargs;
01236
01237
01238 for (parm = TYPE_ACTUAL_ARG_TYPES (oldtype),
01239 type = TYPE_ARG_TYPES (newtype),
01240 nargs = 1;
01241 ;
01242 parm = TREE_CHAIN (parm), type = TREE_CHAIN (type), nargs++)
01243 {
01244 if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node
01245 && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
01246 {
01247 warning_with_decl (newdecl, "prototype for `%s' follows");
01248 warning_with_decl (olddecl, "non-prototype definition here");
01249 break;
01250 }
01251 if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node
01252 || TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
01253 {
01254 error_with_decl (newdecl,
01255 "prototype for `%s' follows and number of arguments doesn't match");
01256 error_with_decl (olddecl, "non-prototype definition here");
01257 errmsg = 1;
01258 break;
01259 }
01260
01261
01262 if (! comptypes (TREE_VALUE (parm), TREE_VALUE (type)))
01263 {
01264 error_with_decl (newdecl,
01265 "prototype for `%s' follows and argument %d doesn't match",
01266 nargs);
01267 error_with_decl (olddecl, "non-prototype definition here");
01268 errmsg = 1;
01269 break;
01270 }
01271 }
01272 }
01273
01274 else
01275 {
01276
01277
01278 if (TREE_CODE (olddecl) == FUNCTION_DECL
01279 && ! DECL_DECLARED_INLINE_P (olddecl)
01280 && DECL_DECLARED_INLINE_P (newdecl)
01281 && TREE_USED (olddecl))
01282 warning_with_decl (newdecl,
01283 "`%s' declared inline after being called");
01284 if (TREE_CODE (olddecl) == FUNCTION_DECL
01285 && ! DECL_DECLARED_INLINE_P (olddecl)
01286 && DECL_DECLARED_INLINE_P (newdecl)
01287 && DECL_INITIAL (olddecl) != 0)
01288 warning_with_decl (newdecl,
01289 "`%s' declared inline after its definition");
01290
01291
01292
01293 if ((pedantic || TREE_CODE (olddecl) == FUNCTION_DECL)
01294 && TREE_PUBLIC (olddecl)
01295 && !TREE_PUBLIC (newdecl))
01296 warning_with_decl (newdecl, "static declaration for `%s' follows non-static");
01297
01298
01299
01300 if (warn_traditional && !in_system_header
01301 && TREE_CODE (olddecl) == FUNCTION_DECL
01302 && !TREE_PUBLIC (olddecl)
01303 && TREE_PUBLIC (newdecl))
01304 warning_with_decl (newdecl, "non-static declaration for `%s' follows static");
01305
01306
01307
01308 if (TREE_CODE (olddecl) != FUNCTION_DECL
01309 && !TREE_READONLY (olddecl)
01310 && TREE_READONLY (newdecl))
01311 warning_with_decl (newdecl, "const declaration for `%s' follows non-const");
01312
01313
01314
01315 else if (pedantic && TREE_CODE (olddecl) != FUNCTION_DECL
01316 && (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)
01317 || TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)))
01318 pedwarn_with_decl (newdecl, "type qualifiers for `%s' conflict with previous decl");
01319 }
01320 }
01321
01322
01323 if (errmsg == 0 && warn_redundant_decls && DECL_SOURCE_LINE (olddecl) != 0
01324
01325
01326 && !(TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) != 0
01327 && DECL_INITIAL (olddecl) == 0)
01328
01329 && !(DECL_EXTERNAL (olddecl) && ! DECL_EXTERNAL (newdecl)))
01330 {
01331 warning_with_decl (newdecl, "redundant redeclaration of `%s' in same scope");
01332 warning_with_decl (olddecl, "previous declaration of `%s'");
01333 }
01334
01335
01336
01337
01338
01339
01340
01341 if (types_match)
01342 {
01343
01344
01345
01346 tree write_olddecl = different_binding_level ? newdecl : olddecl;
01347
01348
01349 if (TREE_CODE (newdecl) != FUNCTION_DECL || !DECL_BUILT_IN (olddecl))
01350 {
01351 if (different_binding_level)
01352 {
01353 if (TYPE_ARG_TYPES (oldtype) != 0
01354 && TYPE_ARG_TYPES (newtype) == 0)
01355 TREE_TYPE (newdecl) = common_type (newtype, oldtype);
01356 else
01357 TREE_TYPE (newdecl)
01358 = build_type_attribute_variant
01359 (newtype,
01360 merge_attributes (TYPE_ATTRIBUTES (newtype),
01361 TYPE_ATTRIBUTES (oldtype)));
01362 }
01363 else
01364 TREE_TYPE (newdecl)
01365 = TREE_TYPE (olddecl)
01366 = common_type (newtype, oldtype);
01367 }
01368
01369
01370 if (oldtype != TREE_TYPE (newdecl))
01371 {
01372 if (TREE_TYPE (newdecl) != error_mark_node)
01373 layout_type (TREE_TYPE (newdecl));
01374 if (TREE_CODE (newdecl) != FUNCTION_DECL
01375 && TREE_CODE (newdecl) != TYPE_DECL
01376 && TREE_CODE (newdecl) != CONST_DECL)
01377 layout_decl (newdecl, 0);
01378 }
01379 else
01380 {
01381
01382 DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
01383 DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
01384 DECL_MODE (newdecl) = DECL_MODE (olddecl);
01385 if (TREE_CODE (olddecl) != FUNCTION_DECL)
01386 if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
01387 {
01388 DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
01389 DECL_USER_ALIGN (newdecl) |= DECL_ALIGN (olddecl);
01390 }
01391 }
01392
01393
01394 COPY_DECL_RTL (olddecl, newdecl);
01395
01396
01397 if (TREE_READONLY (newdecl))
01398 TREE_READONLY (write_olddecl) = 1;
01399
01400 if (TREE_THIS_VOLATILE (newdecl))
01401 {
01402 TREE_THIS_VOLATILE (write_olddecl) = 1;
01403 if (TREE_CODE (newdecl) == VAR_DECL
01404
01405
01406
01407
01408
01409
01410 && errmsg == 0)
01411 make_var_volatile (newdecl);
01412 }
01413
01414
01415
01416
01417 if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0
01418 && ! different_binding_level)
01419 {
01420 DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl);
01421 DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl);
01422 }
01423
01424
01425 if (DECL_IN_SYSTEM_HEADER (olddecl))
01426 DECL_IN_SYSTEM_HEADER (newdecl) = 1;
01427 else if (DECL_IN_SYSTEM_HEADER (newdecl))
01428 DECL_IN_SYSTEM_HEADER (write_olddecl) = 1;
01429
01430
01431
01432
01433
01434 if (DECL_INITIAL (newdecl) == 0 && ! different_binding_level)
01435 DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
01436
01437
01438
01439
01440
01441 if (DECL_SECTION_NAME (newdecl) == NULL_TREE)
01442 DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl);
01443
01444
01445
01446 COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
01447
01448 if (TREE_CODE (newdecl) == FUNCTION_DECL)
01449 {
01450 DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
01451 DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
01452 DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl);
01453 DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
01454 |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl);
01455 #ifdef SGI_MONGOOSE
01456 DECL_SYSCALL_LINKAGE(newdecl) |= DECL_SYSCALL_LINKAGE(olddecl);
01457 DECL_WIDEN_RETVAL(newdecl) |= DECL_WIDEN_RETVAL(olddecl);
01458 #endif
01459 }
01460 }
01461
01462
01463 else if (! different_binding_level)
01464 {
01465 TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
01466 TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
01467 TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
01468 TREE_SIDE_EFFECTS (olddecl) = TREE_SIDE_EFFECTS (newdecl);
01469 }
01470
01471
01472 merge_weak (newdecl, olddecl);
01473
01474
01475 if (TREE_CODE (newdecl) == FUNCTION_DECL)
01476 {
01477 TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
01478
01479
01480
01481
01482 TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
01483
01484 if (! TREE_PUBLIC (olddecl))
01485 TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
01486 }
01487 if (DECL_EXTERNAL (newdecl))
01488 {
01489 if (! different_binding_level)
01490 {
01491
01492
01493
01494 TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
01495 DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
01496 }
01497
01498 TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
01499 if (! DECL_EXTERNAL (newdecl))
01500 DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
01501 }
01502 else
01503 {
01504 #ifdef SGI_MONGOOSE
01505 if (TREE_CODE(olddecl) == VAR_DECL && DECL_ST(olddecl))
01506 WFE_Resolve_Duplicate_Decls (olddecl, newdecl);
01507 #endif
01508 TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
01509 TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
01510 }
01511
01512 if (TREE_CODE (newdecl) == FUNCTION_DECL)
01513 {
01514
01515
01516
01517
01518 if (new_is_definition && DECL_INITIAL (olddecl))
01519 {
01520 if (TREE_USED (olddecl))
01521 (*debug_hooks->outlining_inline_function) (olddecl);
01522
01523
01524 DECL_INLINE (newdecl) = 0;
01525 DECL_UNINLINABLE (newdecl) = 1;
01526 }
01527 else
01528 {
01529
01530
01531 if (DECL_DECLARED_INLINE_P (newdecl)
01532 || DECL_DECLARED_INLINE_P (olddecl))
01533 DECL_DECLARED_INLINE_P (newdecl) = 1;
01534
01535 DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl)
01536 = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl));
01537 }
01538
01539 if (DECL_BUILT_IN (olddecl))
01540 {
01541
01542
01543 if (! types_match || new_is_definition)
01544 {
01545 if (! different_binding_level)
01546 {
01547 TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
01548 DECL_BUILT_IN_CLASS (olddecl) = NOT_BUILT_IN;
01549 }
01550 }
01551 else
01552 {
01553
01554
01555 DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
01556 DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
01557 }
01558 }
01559
01560
01561 if (! new_is_definition)
01562 {
01563 DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
01564
01565
01566
01567 if (! different_binding_level)
01568 DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
01569 DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl);
01570 DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
01571 DECL_NUM_STMTS (newdecl) = DECL_NUM_STMTS (olddecl);
01572 DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
01573
01574
01575
01576 if (DECL_INLINE (olddecl) && ! DECL_UNINLINABLE (newdecl))
01577 {
01578 DECL_INLINE (newdecl) = 1;
01579 DECL_ABSTRACT_ORIGIN (newdecl)
01580 = (different_binding_level
01581 ? DECL_ORIGIN (olddecl)
01582 : DECL_ABSTRACT_ORIGIN (olddecl));
01583 }
01584 }
01585 else
01586 {
01587
01588
01589 if (DECL_DECLARED_INLINE_P (newdecl)
01590 && ! DECL_UNINLINABLE (newdecl))
01591 DECL_INLINE (newdecl) = 1;
01592 }
01593 }
01594 if (different_binding_level)
01595 #ifdef SGI_MONGOOSE
01596 {
01597 if (DECL_ST(olddecl) == 0)
01598 DECL_ST(olddecl) = Create_ST_For_Tree (olddecl);
01599 DECL_ST(newdecl) = DECL_ST(olddecl);
01600 #endif
01601 return 0;
01602 #ifdef SGI_MONGOOSE
01603 }
01604 #endif
01605
01606
01607
01608 {
01609 unsigned olddecl_uid = DECL_UID (olddecl);
01610 #ifdef SGI_MONGOOSE
01611 ST* st = DECL_ST(olddecl);
01612 ST* st2 = DECL_ST2(olddecl);
01613 #endif
01614
01615 #ifdef KEY
01616 unsigned always_inline_attrib = DECL_ALWAYS_INLINE_ATTRIB (olddecl);
01617 unsigned noinline_attrib = DECL_NOINLINE_ATTRIB (olddecl);
01618 #endif
01619
01620 memcpy ((char *) olddecl + sizeof (struct tree_common),
01621 (char *) newdecl + sizeof (struct tree_common),
01622 sizeof (struct tree_decl) - sizeof (struct tree_common));
01623 DECL_UID (olddecl) = olddecl_uid;
01624 #ifdef SGI_MONGOOSE
01625 DECL_ST (olddecl) = st;
01626 DECL_ST (newdecl) = st;
01627 DECL_ST2 (olddecl) = st2;
01628 DECL_ST2 (newdecl) = st2;
01629 #endif
01630
01631 #ifdef KEY
01632
01633 DECL_ALWAYS_INLINE_ATTRIB (olddecl) = DECL_ALWAYS_INLINE_ATTRIB (newdecl)
01634 = always_inline_attrib;
01635 DECL_NOINLINE_ATTRIB (olddecl) = DECL_NOINLINE_ATTRIB (newdecl)
01636 = noinline_attrib;
01637 #endif
01638 }
01639
01640
01641
01642 DECL_ATTRIBUTES (olddecl) = DECL_ATTRIBUTES (newdecl);
01643
01644
01645
01646
01647 if (DECL_RTL_SET_P (olddecl)
01648 && (TREE_CODE (olddecl) == FUNCTION_DECL
01649 || (TREE_CODE (olddecl) == VAR_DECL
01650 && TREE_STATIC (olddecl))))
01651 make_decl_rtl (olddecl, NULL);
01652
01653 return 1;
01654 }
01655
01656
01657
01658
01659 static void
01660 warn_if_shadowing (x, oldlocal)
01661 tree x, oldlocal;
01662 {
01663 tree name;
01664
01665 if (DECL_EXTERNAL (x))
01666 return;
01667
01668 name = DECL_NAME (x);
01669
01670
01671 if (oldlocal != 0
01672
01673 && ! current_binding_level->parm_flag
01674
01675 && current_binding_level->level_chain->parm_flag
01676
01677
01678 && chain_member (oldlocal, current_binding_level->level_chain->names))
01679 {
01680 if (TREE_CODE (oldlocal) == PARM_DECL)
01681 pedwarn ("declaration of `%s' shadows a parameter",
01682 IDENTIFIER_POINTER (name));
01683 else
01684 pedwarn ("declaration of `%s' shadows a symbol from the parameter list",
01685 IDENTIFIER_POINTER (name));
01686 }
01687
01688 else if (warn_shadow
01689
01690 && DECL_SOURCE_LINE (x) != 0
01691
01692 && ! DECL_FROM_INLINE (x))
01693 {
01694 if (TREE_CODE (x) == PARM_DECL
01695 && current_binding_level->level_chain->parm_flag)
01696
01697
01698
01699
01700
01701 ;
01702 else if (oldlocal)
01703 {
01704 if (TREE_CODE (oldlocal) == PARM_DECL)
01705 shadow_warning ("a parameter", name, oldlocal);
01706 else
01707 shadow_warning ("a previous local", name, oldlocal);
01708 }
01709 else if (IDENTIFIER_GLOBAL_VALUE (name) != 0
01710 && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node)
01711 shadow_warning ("a global declaration", name,
01712 IDENTIFIER_GLOBAL_VALUE (name));
01713 }
01714 }
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724 tree
01725 pushdecl (x)
01726 tree x;
01727 {
01728 tree t;
01729 tree name = DECL_NAME (x);
01730 struct binding_level *b = current_binding_level;
01731
01732
01733 if (TREE_CODE (x) == FUNCTION_DECL && ! DECL_LANG_SPECIFIC (x))
01734 DECL_LANG_SPECIFIC (x) = (struct lang_decl *)
01735 ggc_alloc_cleared (sizeof (struct lang_decl));
01736
01737 DECL_CONTEXT (x) = current_function_decl;
01738
01739
01740
01741 if ((TREE_CODE (x) == FUNCTION_DECL || TREE_CODE (x) == VAR_DECL)
01742 && DECL_INITIAL (x) == 0 && DECL_EXTERNAL (x))
01743 DECL_CONTEXT (x) = 0;
01744
01745 if (name)
01746 {
01747 int different_binding_level = 0;
01748
01749 if (warn_nested_externs
01750 && DECL_EXTERNAL (x)
01751 && b != global_binding_level
01752 && x != IDENTIFIER_IMPLICIT_DECL (name)
01753
01754 && !DECL_IN_SYSTEM_HEADER (x))
01755 warning ("nested extern declaration of `%s'",
01756 IDENTIFIER_POINTER (name));
01757
01758 t = lookup_name_current_level (name);
01759 if (! t && DECL_EXTERNAL (x) && TREE_PUBLIC (x))
01760 {
01761 t = IDENTIFIER_GLOBAL_VALUE (name);
01762
01763
01764 if (! t || TREE_CODE (t) == TYPE_DECL)
01765
01766
01767 t = IDENTIFIER_LIMBO_VALUE (name);
01768 different_binding_level = 1;
01769 }
01770 if (t != 0 && t == error_mark_node)
01771
01772 {
01773 t = 0;
01774 error_with_decl (x, "`%s' used prior to declaration");
01775 }
01776
01777
01778
01779 if (TREE_PUBLIC (name)
01780
01781
01782 && ! TREE_PUBLIC (x)
01783 && (TREE_CODE (x) == FUNCTION_DECL || b == global_binding_level)
01784
01785
01786 && IDENTIFIER_IMPLICIT_DECL (name) != 0)
01787 {
01788 pedwarn ("`%s' was declared implicitly `extern' and later `static'",
01789 IDENTIFIER_POINTER (name));
01790 pedwarn_with_file_and_line
01791 (DECL_SOURCE_FILE (IDENTIFIER_IMPLICIT_DECL (name)),
01792 DECL_SOURCE_LINE (IDENTIFIER_IMPLICIT_DECL (name)),
01793 "previous declaration of `%s'",
01794 IDENTIFIER_POINTER (name));
01795 TREE_THIS_VOLATILE (name) = 1;
01796 }
01797
01798 if (t != 0 && duplicate_decls (x, t, different_binding_level))
01799 {
01800 if (TREE_CODE (t) == PARM_DECL)
01801 {
01802
01803
01804 TREE_ASM_WRITTEN (t) = TREE_ASM_WRITTEN (x);
01805 return t;
01806 }
01807 return t;
01808 }
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853 if (TREE_CODE (x) == TYPE_DECL)
01854 {
01855 if (DECL_SOURCE_LINE (x) == 0)
01856 {
01857 if (TYPE_NAME (TREE_TYPE (x)) == 0)
01858 TYPE_NAME (TREE_TYPE (x)) = x;
01859 }
01860 else if (TREE_TYPE (x) != error_mark_node
01861 && DECL_ORIGINAL_TYPE (x) == NULL_TREE)
01862 {
01863 tree tt = TREE_TYPE (x);
01864 DECL_ORIGINAL_TYPE (x) = tt;
01865 tt = build_type_copy (tt);
01866 TYPE_NAME (tt) = x;
01867 TREE_USED (tt) = TREE_USED (x);
01868 TREE_TYPE (x) = tt;
01869 }
01870 }
01871
01872
01873
01874
01875 if (TREE_PUBLIC (x)
01876 && ! (TREE_CODE (x) == FUNCTION_DECL && DECL_INLINE (x)))
01877 {
01878 tree decl;
01879
01880 if (IDENTIFIER_LIMBO_VALUE (name) != 0)
01881
01882 decl = IDENTIFIER_LIMBO_VALUE (name);
01883 else
01884 decl = 0;
01885
01886 if (decl && ! comptypes (TREE_TYPE (x), TREE_TYPE (decl))
01887
01888 && !DECL_BUILT_IN (decl))
01889 {
01890 pedwarn_with_decl (x,
01891 "type mismatch with previous external decl");
01892 pedwarn_with_decl (decl, "previous external decl of `%s'");
01893 }
01894 }
01895
01896
01897
01898
01899 if (IDENTIFIER_IMPLICIT_DECL (name) != 0
01900 && IDENTIFIER_GLOBAL_VALUE (name) == 0
01901 && TREE_CODE (x) == FUNCTION_DECL
01902 && ! comptypes (TREE_TYPE (x),
01903 TREE_TYPE (IDENTIFIER_IMPLICIT_DECL (name))))
01904 {
01905 warning_with_decl (x, "type mismatch with previous implicit declaration");
01906 warning_with_decl (IDENTIFIER_IMPLICIT_DECL (name),
01907 "previous implicit declaration of `%s'");
01908 }
01909
01910
01911
01912 if (b == global_binding_level)
01913 {
01914
01915
01916
01917
01918 if (IDENTIFIER_GLOBAL_VALUE (name) == 0 && TREE_PUBLIC (x))
01919 TREE_PUBLIC (name) = 1;
01920
01921 IDENTIFIER_GLOBAL_VALUE (name) = x;
01922
01923
01924 IDENTIFIER_LIMBO_VALUE (name) = 0;
01925
01926
01927 if (IDENTIFIER_IMPLICIT_DECL (name)
01928 && TREE_USED (IDENTIFIER_IMPLICIT_DECL (name)))
01929 TREE_USED (x) = 1, TREE_USED (name) = 1;
01930
01931
01932 if (IDENTIFIER_IMPLICIT_DECL (name)
01933 && TREE_ADDRESSABLE (IDENTIFIER_IMPLICIT_DECL (name)))
01934 TREE_ADDRESSABLE (x) = 1;
01935
01936
01937 if (IDENTIFIER_IMPLICIT_DECL (name) != 0
01938
01939 && ! (TREE_CODE (x) == FUNCTION_DECL
01940 && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (x)))
01941 == integer_type_node)))
01942 pedwarn ("`%s' was previously implicitly declared to return `int'",
01943 IDENTIFIER_POINTER (name));
01944
01945
01946
01947 if (TREE_PUBLIC (name)
01948 && ! TREE_PUBLIC (x) && ! DECL_EXTERNAL (x))
01949 {
01950
01951 if (t != 0 && DECL_BUILT_IN (t))
01952 ;
01953
01954 else if (t != 0 && DECL_BUILT_IN_NONANSI (t))
01955 ;
01956
01957
01958 else if (TREE_CODE (x) == TYPE_DECL)
01959 ;
01960 else if (IDENTIFIER_IMPLICIT_DECL (name))
01961 {
01962 if (! TREE_THIS_VOLATILE (name))
01963 pedwarn ("`%s' was declared implicitly `extern' and later `static'",
01964 IDENTIFIER_POINTER (name));
01965 }
01966 else
01967 pedwarn ("`%s' was declared `extern' and later `static'",
01968 IDENTIFIER_POINTER (name));
01969 }
01970 }
01971 else
01972 {
01973
01974 tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
01975 tree oldglobal = IDENTIFIER_GLOBAL_VALUE (name);
01976
01977 IDENTIFIER_LOCAL_VALUE (name) = x;
01978
01979
01980
01981 if (oldlocal == 0
01982 && oldglobal != 0
01983 && TREE_CODE (x) == FUNCTION_DECL
01984 && TREE_CODE (oldglobal) == FUNCTION_DECL
01985 && DECL_EXTERNAL (x)
01986 && ! DECL_DECLARED_INLINE_P (x))
01987 {
01988
01989 if (! comptypes (TREE_TYPE (x),
01990 TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name))))
01991 pedwarn_with_decl (x, "extern declaration of `%s' doesn't match global one");
01992 else
01993 {
01994
01995
01996 if (DECL_DECLARED_INLINE_P (oldglobal))
01997 {
01998 DECL_DECLARED_INLINE_P (x)
01999 = DECL_DECLARED_INLINE_P (oldglobal);
02000 DECL_INLINE (x) = DECL_INLINE (oldglobal);
02001 DECL_INITIAL (x) = (current_function_decl == oldglobal
02002 ? 0 : DECL_INITIAL (oldglobal));
02003 DECL_SAVED_INSNS (x) = DECL_SAVED_INSNS (oldglobal);
02004 DECL_NUM_STMTS (x) = DECL_NUM_STMTS (oldglobal);
02005 DECL_ARGUMENTS (x) = DECL_ARGUMENTS (oldglobal);
02006 DECL_RESULT (x) = DECL_RESULT (oldglobal);
02007 TREE_ASM_WRITTEN (x) = TREE_ASM_WRITTEN (oldglobal);
02008 DECL_ABSTRACT_ORIGIN (x)
02009 = DECL_ABSTRACT_ORIGIN (oldglobal);
02010 }
02011
02012 if (DECL_BUILT_IN (oldglobal))
02013 {
02014 DECL_BUILT_IN_CLASS (x) = DECL_BUILT_IN_CLASS (oldglobal);
02015 DECL_FUNCTION_CODE (x) = DECL_FUNCTION_CODE (oldglobal);
02016 }
02017
02018 if (TYPE_ARG_TYPES (TREE_TYPE (oldglobal)) != 0
02019 && DECL_INITIAL (oldglobal)
02020 && TYPE_ARG_TYPES (TREE_TYPE (x)) == 0)
02021 TREE_TYPE (x) = TREE_TYPE (oldglobal);
02022 }
02023 }
02024
02025 #if 0
02026
02027
02028
02029
02030 if (oldlocal == 0 && oldglobal != 0
02031 && !TREE_PUBLIC (oldglobal)
02032 && DECL_EXTERNAL (x) && TREE_PUBLIC (x))
02033 warning ("`%s' locally external but globally static",
02034 IDENTIFIER_POINTER (name));
02035 #endif
02036
02037
02038
02039
02040 if (oldlocal == 0
02041 && DECL_EXTERNAL (x)
02042 && TREE_PUBLIC (x))
02043 {
02044 if (oldglobal == 0)
02045 TREE_PUBLIC (name) = 1;
02046
02047
02048
02049
02050
02051
02052
02053
02054 if (IDENTIFIER_LIMBO_VALUE (name) == 0)
02055 IDENTIFIER_LIMBO_VALUE (name) = x;
02056 }
02057
02058 warn_if_shadowing (x, oldlocal);
02059
02060
02061
02062 if (oldlocal != 0)
02063 b->shadowed = tree_cons (name, oldlocal, b->shadowed);
02064 }
02065
02066
02067
02068
02069
02070 if (TREE_TYPE (x) != error_mark_node
02071 && !COMPLETE_TYPE_P (TREE_TYPE (x)))
02072 {
02073 tree element = TREE_TYPE (x);
02074
02075 while (TREE_CODE (element) == ARRAY_TYPE)
02076 element = TREE_TYPE (element);
02077 if ((TREE_CODE (element) == RECORD_TYPE
02078 || TREE_CODE (element) == UNION_TYPE)
02079 && (TREE_CODE (x) != TYPE_DECL
02080 || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE))
02081 b->incomplete_list = tree_cons (NULL_TREE, x, b->incomplete_list);
02082 }
02083 }
02084
02085
02086
02087 TREE_CHAIN (x) = b->names;
02088 b->names = x;
02089
02090 return x;
02091 }
02092
02093
02094
02095 tree
02096 pushdecl_top_level (x)
02097 tree x;
02098 {
02099 tree t;
02100 struct binding_level *b = current_binding_level;
02101
02102 current_binding_level = global_binding_level;
02103 t = pushdecl (x);
02104 current_binding_level = b;
02105 return t;
02106 }
02107
02108
02109
02110
02111 tree
02112 implicitly_declare (functionid)
02113 tree functionid;
02114 {
02115 tree decl;
02116 int traditional_warning = 0;
02117
02118 int implicit_warning;
02119
02120
02121
02122
02123 #if 0
02124 if (IDENTIFIER_IMPLICIT_DECL (functionid) != 0)
02125 decl = IDENTIFIER_IMPLICIT_DECL (functionid);
02126 else
02127 #endif
02128 decl = build_decl (FUNCTION_DECL, functionid, default_function_type);
02129
02130
02131
02132 if (TREE_PUBLIC (functionid) && IDENTIFIER_GLOBAL_VALUE (functionid) == 0)
02133 traditional_warning = 1;
02134
02135
02136 implicit_warning = (IDENTIFIER_IMPLICIT_DECL (functionid) == 0);
02137
02138 DECL_EXTERNAL (decl) = 1;
02139 TREE_PUBLIC (decl) = 1;
02140
02141
02142 IDENTIFIER_IMPLICIT_DECL (functionid) = decl;
02143
02144
02145
02146 pushdecl (decl);
02147
02148
02149 if (flag_objc)
02150 objc_check_decl (decl);
02151
02152 rest_of_decl_compilation (decl, NULL, 0, 0);
02153
02154 if (implicit_warning)
02155 implicit_decl_warning (functionid);
02156 else if (warn_traditional && traditional_warning)
02157 warning ("function `%s' was previously declared within a block",
02158 IDENTIFIER_POINTER (functionid));
02159
02160
02161
02162
02163 gen_aux_info_record (decl, 0, 1, 0);
02164
02165
02166 decl_attributes (&decl, NULL_TREE, 0);
02167
02168 return decl;
02169 }
02170
02171 void
02172 implicit_decl_warning (id)
02173 tree id;
02174 {
02175 const char *name = IDENTIFIER_POINTER (id);
02176 if (mesg_implicit_function_declaration == 2)
02177 error ("implicit declaration of function `%s'", name);
02178 else if (mesg_implicit_function_declaration == 1)
02179 warning ("implicit declaration of function `%s'", name);
02180 }
02181
02182
02183
02184
02185
02186
02187
02188 static int
02189 redeclaration_error_message (newdecl, olddecl)
02190 tree newdecl, olddecl;
02191 {
02192 if (TREE_CODE (newdecl) == TYPE_DECL)
02193 {
02194
02195
02196 if (DECL_IN_SYSTEM_HEADER (olddecl) || DECL_IN_SYSTEM_HEADER (newdecl))
02197 return 0;
02198 return 1;
02199 }
02200 else if (TREE_CODE (newdecl) == FUNCTION_DECL)
02201 {
02202
02203
02204
02205
02206 if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0
02207
02208
02209 && ! (DECL_DECLARED_INLINE_P (olddecl) && DECL_EXTERNAL (olddecl)
02210 && ! (DECL_DECLARED_INLINE_P (newdecl)
02211 && DECL_EXTERNAL (newdecl))))
02212 return 1;
02213 return 0;
02214 }
02215 else if (DECL_CONTEXT (newdecl) == NULL_TREE)
02216 {
02217
02218
02219 if (DECL_EXTERNAL (newdecl) || DECL_EXTERNAL (olddecl))
02220 return 0;
02221
02222 if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0)
02223 return 1;
02224
02225
02226 if (TREE_PUBLIC (olddecl) != TREE_PUBLIC (newdecl))
02227 return 3;
02228 return 0;
02229 }
02230 else if (current_binding_level->parm_flag
02231 && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
02232 return 0;
02233 else
02234 {
02235
02236
02237
02238
02239 if (!(DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl))
02240 && DECL_CONTEXT (newdecl) == DECL_CONTEXT (olddecl))
02241 return 2;
02242 return 0;
02243 }
02244 }
02245
02246
02247
02248
02249
02250 tree
02251 lookup_label (id)
02252 tree id;
02253 {
02254 tree decl = IDENTIFIER_LABEL_VALUE (id);
02255
02256 if (current_function_decl == 0)
02257 {
02258 error ("label %s referenced outside of any function",
02259 IDENTIFIER_POINTER (id));
02260 return 0;
02261 }
02262
02263
02264 if (decl != 0)
02265 {
02266
02267 if (DECL_CONTEXT (decl) != current_function_decl
02268 && ! C_DECLARED_LABEL_FLAG (decl))
02269 return shadow_label (id);
02270 return decl;
02271 }
02272
02273 decl = build_decl (LABEL_DECL, id, void_type_node);
02274
02275
02276 DECL_CONTEXT (decl) = current_function_decl;
02277
02278 DECL_MODE (decl) = VOIDmode;
02279
02280
02281
02282 DECL_SOURCE_LINE (decl) = lineno;
02283 DECL_SOURCE_FILE (decl) = input_filename;
02284
02285 IDENTIFIER_LABEL_VALUE (id) = decl;
02286
02287 named_labels = tree_cons (NULL_TREE, decl, named_labels);
02288
02289 return decl;
02290 }
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300 tree
02301 shadow_label (name)
02302 tree name;
02303 {
02304 tree decl = IDENTIFIER_LABEL_VALUE (name);
02305
02306 if (decl != 0)
02307 {
02308 tree dup;
02309
02310
02311
02312 for (dup = named_labels; dup; dup = TREE_CHAIN (dup))
02313 if (TREE_VALUE (dup) == decl)
02314 {
02315 error ("duplicate label declaration `%s'",
02316 IDENTIFIER_POINTER (name));
02317 error_with_decl (TREE_VALUE (dup),
02318 "this is a previous declaration");
02319
02320 return lookup_label (name);
02321 }
02322
02323 shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
02324 IDENTIFIER_LABEL_VALUE (name) = decl = 0;
02325 }
02326
02327 return lookup_label (name);
02328 }
02329
02330
02331
02332
02333
02334 tree
02335 define_label (filename, line, name)
02336 const char *filename;
02337 int line;
02338 tree name;
02339 {
02340 tree decl = lookup_label (name);
02341
02342
02343 if (decl != 0 && DECL_CONTEXT (decl) != current_function_decl)
02344 {
02345 shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
02346 IDENTIFIER_LABEL_VALUE (name) = 0;
02347 decl = lookup_label (name);
02348 }
02349
02350 if (warn_traditional && !in_system_header && lookup_name (name))
02351 warning_with_file_and_line (filename, line,
02352 "traditional C lacks a separate namespace for labels, identifier `%s' conflicts",
02353 IDENTIFIER_POINTER (name));
02354
02355 if (DECL_INITIAL (decl) != 0)
02356 {
02357 error_with_file_and_line (filename, line, "duplicate label `%s'",
02358 IDENTIFIER_POINTER (name));
02359 return 0;
02360 }
02361 else
02362 {
02363
02364 DECL_INITIAL (decl) = error_mark_node;
02365
02366 DECL_SOURCE_FILE (decl) = filename;
02367 DECL_SOURCE_LINE (decl) = line;
02368 return decl;
02369 }
02370 }
02371
02372
02373
02374
02375
02376
02377 tree
02378 getdecls ()
02379 {
02380 return current_binding_level->names;
02381 }
02382
02383
02384
02385 tree
02386 gettags ()
02387 {
02388 return current_binding_level->tags;
02389 }
02390
02391
02392
02393
02394
02395 static void
02396 storedecls (decls)
02397 tree decls;
02398 {
02399 current_binding_level->names = decls;
02400 }
02401
02402
02403
02404 static void
02405 storetags (tags)
02406 tree tags;
02407 {
02408 current_binding_level->tags = tags;
02409 }
02410
02411
02412
02413
02414
02415
02416
02417
02418
02419
02420
02421 static tree
02422 lookup_tag (code, name, binding_level, thislevel_only)
02423 enum tree_code code;
02424 struct binding_level *binding_level;
02425 tree name;
02426 int thislevel_only;
02427 {
02428 struct binding_level *level;
02429 int thislevel = 1;
02430
02431 for (level = binding_level; level; level = level->level_chain)
02432 {
02433 tree tail;
02434 for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
02435 {
02436 if (TREE_PURPOSE (tail) == name)
02437 {
02438 if (TREE_CODE (TREE_VALUE (tail)) != code)
02439 {
02440
02441 pending_invalid_xref = name;
02442 pending_invalid_xref_file = input_filename;
02443 pending_invalid_xref_line = lineno;
02444
02445
02446
02447
02448 if (thislevel)
02449 pending_xref_error ();
02450 }
02451 return TREE_VALUE (tail);
02452 }
02453 }
02454 if (! level->tag_transparent)
02455 {
02456 if (thislevel_only)
02457 return NULL_TREE;
02458 thislevel = 0;
02459 }
02460 }
02461 return NULL_TREE;
02462 }
02463
02464
02465
02466
02467
02468
02469 void
02470 pending_xref_error ()
02471 {
02472 if (pending_invalid_xref != 0)
02473 error_with_file_and_line (pending_invalid_xref_file,
02474 pending_invalid_xref_line,
02475 "`%s' defined as wrong kind of tag",
02476 IDENTIFIER_POINTER (pending_invalid_xref));
02477 pending_invalid_xref = 0;
02478 }
02479
02480
02481
02482
02483 static tree
02484 lookup_tag_reverse (type)
02485 tree type;
02486 {
02487 struct binding_level *level;
02488
02489 for (level = current_binding_level; level; level = level->level_chain)
02490 {
02491 tree tail;
02492 for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
02493 {
02494 if (TREE_VALUE (tail) == type)
02495 return TREE_PURPOSE (tail);
02496 }
02497 }
02498 return NULL_TREE;
02499 }
02500
02501
02502
02503
02504
02505
02506 tree
02507 lookup_name (name)
02508 tree name;
02509 {
02510 tree val;
02511
02512 if (current_binding_level != global_binding_level
02513 && IDENTIFIER_LOCAL_VALUE (name))
02514 val = IDENTIFIER_LOCAL_VALUE (name);
02515 else
02516 val = IDENTIFIER_GLOBAL_VALUE (name);
02517 return val;
02518 }
02519
02520
02521
02522 tree
02523 lookup_name_current_level (name)
02524 tree name;
02525 {
02526 tree t;
02527
02528 if (current_binding_level == global_binding_level)
02529 return IDENTIFIER_GLOBAL_VALUE (name);
02530
02531 if (IDENTIFIER_LOCAL_VALUE (name) == 0)
02532 return 0;
02533
02534 for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
02535 if (DECL_NAME (t) == name)
02536 break;
02537
02538 return t;
02539 }
02540
02541
02542
02543
02544
02545
02546 void
02547 c_init_decl_processing ()
02548 {
02549 tree endlink;
02550 tree ptr_ftype_void, ptr_ftype_ptr;
02551
02552
02553 c_parse_init ();
02554
02555 current_function_decl = NULL;
02556 named_labels = NULL;
02557 current_binding_level = NULL_BINDING_LEVEL;
02558 free_binding_level = NULL_BINDING_LEVEL;
02559
02560
02561 pushlevel (0);
02562 global_binding_level = current_binding_level;
02563
02564 build_common_tree_nodes (flag_signed_char);
02565
02566 c_common_nodes_and_builtins ();
02567
02568 boolean_type_node = integer_type_node;
02569 boolean_true_node = integer_one_node;
02570 boolean_false_node = integer_zero_node;
02571
02572 c_bool_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
02573 TREE_SET_CODE (c_bool_type_node, BOOLEAN_TYPE);
02574 TYPE_MAX_VALUE (c_bool_type_node) = build_int_2 (1, 0);
02575 TREE_TYPE (TYPE_MAX_VALUE (c_bool_type_node)) = c_bool_type_node;
02576 TYPE_PRECISION (c_bool_type_node) = 1;
02577 pushdecl (build_decl (TYPE_DECL, get_identifier ("_Bool"),
02578 c_bool_type_node));
02579 c_bool_false_node = build_int_2 (0, 0);
02580 TREE_TYPE (c_bool_false_node) = c_bool_type_node;
02581 c_bool_true_node = build_int_2 (1, 0);
02582 TREE_TYPE (c_bool_true_node) = c_bool_type_node;
02583
02584 endlink = void_list_node;
02585 ptr_ftype_void = build_function_type (ptr_type_node, endlink);
02586 ptr_ftype_ptr
02587 = build_function_type (ptr_type_node,
02588 tree_cons (NULL_TREE, ptr_type_node, endlink));
02589
02590 pedantic_lvalues = pedantic;
02591
02592 make_fname_decl = c_make_fname_decl;
02593 start_fname_decls ();
02594 }
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604 static tree
02605 c_make_fname_decl (id, type_dep)
02606 tree id;
02607 int type_dep;
02608 {
02609 const char *name = fname_as_string (type_dep);
02610 tree decl, type, init;
02611 size_t length = strlen (name);
02612
02613 type = build_array_type
02614 (build_qualified_type (char_type_node, TYPE_QUAL_CONST),
02615 build_index_type (size_int (length)));
02616
02617 decl = build_decl (VAR_DECL, id, type);
02618
02619 DECL_CONTEXT (decl) = current_function_decl;
02620
02621 TREE_STATIC (decl) = 1;
02622 TREE_READONLY (decl) = 1;
02623 DECL_ARTIFICIAL (decl) = 1;
02624
02625 init = build_string (length + 1, name);
02626 TREE_TYPE (init) = type;
02627 DECL_INITIAL (decl) = init;
02628
02629 TREE_USED (decl) = 1;
02630
02631 finish_decl (decl, init, NULL_TREE);
02632
02633 return decl;
02634 }
02635
02636
02637
02638
02639
02640
02641
02642
02643
02644
02645 tree
02646 builtin_function (name, type, function_code, class, library_name, attrs)
02647 const char *name;
02648 tree type;
02649 int function_code;
02650 enum built_in_class class;
02651 const char *library_name;
02652 tree attrs;
02653 {
02654 tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
02655 DECL_EXTERNAL (decl) = 1;
02656 TREE_PUBLIC (decl) = 1;
02657 if (library_name)
02658 SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
02659 make_decl_rtl (decl, NULL);
02660 pushdecl (decl);
02661 DECL_BUILT_IN_CLASS (decl) = class;
02662 DECL_FUNCTION_CODE (decl) = function_code;
02663
02664
02665
02666 if (name[0] != '_' || name[1] != '_')
02667 C_DECL_ANTICIPATED (decl) = 1;
02668
02669
02670 if (attrs)
02671 decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN);
02672 else
02673 decl_attributes (&decl, NULL_TREE, 0);
02674
02675 return decl;
02676 }
02677
02678
02679
02680
02681 void
02682 c_insert_default_attributes (decl)
02683 tree decl;
02684 {
02685 if (!TREE_PUBLIC (decl))
02686 return;
02687 c_common_insert_default_attributes (decl);
02688 }
02689
02690
02691
02692
02693
02694
02695
02696
02697
02698 void
02699 shadow_tag (declspecs)
02700 tree declspecs;
02701 {
02702 shadow_tag_warned (declspecs, 0);
02703 }
02704
02705 void
02706 shadow_tag_warned (declspecs, warned)
02707 tree declspecs;
02708 int warned;
02709
02710
02711 {
02712 int found_tag = 0;
02713 tree link;
02714 tree specs, attrs;
02715
02716 pending_invalid_xref = 0;
02717
02718
02719
02720 split_specs_attrs (declspecs, &specs, &attrs);
02721
02722 for (link = specs; link; link = TREE_CHAIN (link))
02723 {
02724 tree value = TREE_VALUE (link);
02725 enum tree_code code = TREE_CODE (value);
02726
02727 if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)
02728
02729
02730 {
02731 tree name = lookup_tag_reverse (value);
02732 tree t;
02733
02734 found_tag++;
02735
02736 if (name == 0)
02737 {
02738 if (warned != 1 && code != ENUMERAL_TYPE)
02739
02740 {
02741 pedwarn ("unnamed struct/union that defines no instances");
02742 warned = 1;
02743 }
02744 }
02745 else
02746 {
02747 t = lookup_tag (code, name, current_binding_level, 1);
02748
02749 if (t == 0)
02750 {
02751 t = make_node (code);
02752 pushtag (name, t);
02753 }
02754 }
02755 }
02756 else
02757 {
02758 if (!warned && ! in_system_header)
02759 {
02760 warning ("useless keyword or type name in empty declaration");
02761 warned = 2;
02762 }
02763 }
02764 }
02765
02766 if (found_tag > 1)
02767 error ("two types specified in one empty declaration");
02768
02769 if (warned != 1)
02770 {
02771 if (found_tag == 0)
02772 pedwarn ("empty declaration");
02773 }
02774 }
02775
02776
02777
02778
02779
02780
02781
02782
02783
02784
02785
02786
02787
02788 tree
02789 build_array_declarator (expr, quals, static_p, vla_unspec_p)
02790 tree expr;
02791 tree quals;
02792 int static_p;
02793 int vla_unspec_p;
02794 {
02795 tree decl;
02796 decl = build_nt (ARRAY_REF, NULL_TREE, expr);
02797 TREE_TYPE (decl) = quals;
02798 TREE_STATIC (decl) = (static_p ? 1 : 0);
02799 if (pedantic && !flag_isoc99)
02800 {
02801 if (static_p || quals != NULL_TREE)
02802 pedwarn ("ISO C90 does not support `static' or type qualifiers in parameter array declarators");
02803 if (vla_unspec_p)
02804 pedwarn ("ISO C90 does not support `[*]' array declarators");
02805 }
02806 if (vla_unspec_p)
02807 warning ("GCC does not yet properly implement `[*]' array declarators");
02808 return decl;
02809 }
02810
02811
02812
02813
02814
02815
02816
02817
02818 tree
02819 set_array_declarator_type (decl, type, abstract_p)
02820 tree decl;
02821 tree type;
02822 int abstract_p;
02823 {
02824 TREE_OPERAND (decl, 0) = type;
02825 if (abstract_p && (TREE_TYPE (decl) != NULL_TREE || TREE_STATIC (decl)))
02826 error ("static or type qualifiers in abstract declarator");
02827 return decl;
02828 }
02829
02830
02831
02832 tree
02833 groktypename (typename)
02834 tree typename;
02835 {
02836 tree specs, attrs;
02837
02838 if (TREE_CODE (typename) != TREE_LIST)
02839 return typename;
02840
02841 split_specs_attrs (TREE_PURPOSE (typename), &specs, &attrs);
02842
02843 typename = grokdeclarator (TREE_VALUE (typename), specs, TYPENAME, 0);
02844
02845
02846 decl_attributes (&typename, attrs, 0);
02847
02848 return typename;
02849 }
02850
02851
02852
02853 tree
02854 groktypename_in_parm_context (typename)
02855 tree typename;
02856 {
02857 if (TREE_CODE (typename) != TREE_LIST)
02858 return typename;
02859 return grokdeclarator (TREE_VALUE (typename),
02860 TREE_PURPOSE (typename),
02861 PARM, 0);
02862 }
02863
02864
02865
02866
02867
02868
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879 tree
02880 start_decl (declarator, declspecs, initialized, attributes)
02881 tree declarator, declspecs;
02882 int initialized;
02883 tree attributes;
02884 {
02885 tree decl;
02886 tree tem;
02887
02888
02889
02890 if (lookup_attribute ("deprecated", attributes))
02891 deprecated_state = DEPRECATED_SUPPRESS;
02892
02893 decl = grokdeclarator (declarator, declspecs,
02894 NORMAL, initialized);
02895
02896 deprecated_state = DEPRECATED_NORMAL;
02897
02898 if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL
02899 && MAIN_NAME_P (DECL_NAME (decl)))
02900 warning_with_decl (decl, "`%s' is usually a function");
02901
02902 if (initialized)
02903
02904
02905
02906 switch (TREE_CODE (decl))
02907 {
02908 case TYPE_DECL:
02909 error ("typedef `%s' is initialized (use __typeof__ instead)",
02910 IDENTIFIER_POINTER (DECL_NAME (decl)));
02911 initialized = 0;
02912 break;
02913
02914 case FUNCTION_DECL:
02915 error ("function `%s' is initialized like a variable",
02916 IDENTIFIER_POINTER (DECL_NAME (decl)));
02917 initialized = 0;
02918 break;
02919
02920 case PARM_DECL:
02921
02922 error ("parameter `%s' is initialized",
02923 IDENTIFIER_POINTER (DECL_NAME (decl)));
02924 initialized = 0;
02925 break;
02926
02927 default:
02928
02929
02930
02931
02932
02933 if (TREE_TYPE (decl) == error_mark_node)
02934 initialized = 0;
02935 else if (COMPLETE_TYPE_P (TREE_TYPE (decl)))
02936 {
02937
02938
02939 if (TREE_CODE (TYPE_SIZE (TREE_TYPE (decl))) != INTEGER_CST
02940 || C_DECL_VARIABLE_SIZE (decl))
02941 {
02942 error ("variable-sized object may not be initialized");
02943 initialized = 0;
02944 }
02945 }
02946 else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
02947 {
02948 error ("variable `%s' has initializer but incomplete type",
02949 IDENTIFIER_POINTER (DECL_NAME (decl)));
02950 initialized = 0;
02951 }
02952 else if (!COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
02953 {
02954 error ("elements of array `%s' have incomplete type",
02955 IDENTIFIER_POINTER (DECL_NAME (decl)));
02956 initialized = 0;
02957 }
02958 }
02959
02960 if (initialized)
02961 {
02962 #if 0
02963
02964 if (current_binding_level != global_binding_level
02965 && DECL_EXTERNAL (decl)
02966 && TREE_CODE (decl) != FUNCTION_DECL)
02967 warning ("declaration of `%s' has `extern' and is initialized",
02968 IDENTIFIER_POINTER (DECL_NAME (decl)));
02969 #endif
02970 DECL_EXTERNAL (decl) = 0;
02971 if (current_binding_level == global_binding_level)
02972 TREE_STATIC (decl) = 1;
02973
02974
02975
02976
02977 DECL_INITIAL (decl) = error_mark_node;
02978 }
02979
02980
02981
02982
02983 if (TREE_CODE (decl) == FUNCTION_DECL)
02984 gen_aux_info_record (decl, 0, 0, TYPE_ARG_TYPES (TREE_TYPE (decl)) != 0);
02985
02986
02987
02988
02989
02990
02991
02992
02993
02994
02995
02996
02997 if (TREE_CODE (decl) == VAR_DECL
02998 && !initialized
02999 && TREE_PUBLIC (decl)
03000 && !DECL_THREAD_LOCAL (decl)
03001 && !flag_no_common)
03002 DECL_COMMON (decl) = 1;
03003
03004
03005 decl_attributes (&decl, attributes, 0);
03006
03007
03008 if (current_binding_level == global_binding_level)
03009 maybe_apply_pragma_weak (decl);
03010
03011 if (TREE_CODE (decl) == FUNCTION_DECL
03012 && DECL_DECLARED_INLINE_P (decl)
03013 && DECL_UNINLINABLE (decl)
03014 && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl)))
03015 warning_with_decl (decl,
03016 "inline function `%s' given attribute noinline");
03017
03018
03019
03020 tem = pushdecl (decl);
03021
03022
03023 if (current_binding_level != global_binding_level
03024
03025
03026
03027 && !DECL_RTL_SET_P (tem)
03028 && !DECL_CONTEXT (tem))
03029 {
03030 if (TREE_TYPE (tem) != error_mark_node
03031 && COMPLETE_TYPE_P (TREE_TYPE (tem)))
03032 expand_decl (tem);
03033 else if (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE
03034 && DECL_INITIAL (tem) != 0)
03035 expand_decl (tem);
03036 }
03037
03038 return tem;
03039 }
03040
03041
03042
03043
03044
03045
03046 void
03047 finish_decl (decl, init, asmspec_tree)
03048 tree decl, init;
03049 tree asmspec_tree;
03050 {
03051 tree type = TREE_TYPE (decl);
03052 int was_incomplete = (DECL_SIZE (decl) == 0);
03053 const char *asmspec = 0;
03054
03055
03056 if (current_binding_level == global_binding_level)
03057 asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree);
03058 if (asmspec_tree)
03059 asmspec = TREE_STRING_POINTER (asmspec_tree);
03060
03061
03062 if (init != 0 && DECL_INITIAL (decl) == 0)
03063 init = 0;
03064
03065
03066 if (TREE_CODE (decl) == PARM_DECL)
03067 init = 0;
03068
03069 if (init)
03070 store_init_value (decl, init);
03071
03072
03073 if (TREE_CODE (type) == ARRAY_TYPE
03074 && TYPE_DOMAIN (type) == 0
03075 && TREE_CODE (decl) != TYPE_DECL)
03076 {
03077 int do_default
03078 = (TREE_STATIC (decl)
03079
03080
03081 ? pedantic && !TREE_PUBLIC (decl)
03082 : !DECL_EXTERNAL (decl));
03083 int failure
03084 = complete_array_type (type, DECL_INITIAL (decl), do_default);
03085
03086
03087 type = TREE_TYPE (decl);
03088
03089 if (failure == 1)
03090 error_with_decl (decl, "initializer fails to determine size of `%s'");
03091
03092 else if (failure == 2)
03093 {
03094 if (do_default)
03095 error_with_decl (decl, "array size missing in `%s'");
03096
03097
03098
03099
03100
03101
03102 else if (!pedantic && TREE_STATIC (decl) && ! TREE_PUBLIC (decl))
03103 DECL_EXTERNAL (decl) = 1;
03104 }
03105
03106
03107
03108
03109 else if (pedantic && TYPE_DOMAIN (type) != 0
03110 && tree_int_cst_sgn (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) < 0)
03111 error_with_decl (decl, "zero or negative size array `%s'");
03112
03113 layout_decl (decl, 0);
03114 }
03115
03116 if (TREE_CODE (decl) == VAR_DECL)
03117 {
03118 if (DECL_SIZE (decl) == 0 && TREE_TYPE (decl) != error_mark_node
03119 && COMPLETE_TYPE_P (TREE_TYPE (decl)))
03120 layout_decl (decl, 0);
03121
03122 if (DECL_SIZE (decl) == 0
03123
03124 && TREE_TYPE (decl) != error_mark_node
03125 && (TREE_STATIC (decl)
03126 ?
03127
03128
03129
03130
03131
03132 (DECL_INITIAL (decl) != 0
03133 || DECL_CONTEXT (decl) != 0)
03134 :
03135
03136
03137 !DECL_EXTERNAL (decl)))
03138 {
03139 error_with_decl (decl, "storage size of `%s' isn't known");
03140 TREE_TYPE (decl) = error_mark_node;
03141 }
03142
03143 if ((DECL_EXTERNAL (decl) || TREE_STATIC (decl))
03144 && DECL_SIZE (decl) != 0)
03145 {
03146 if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
03147 constant_expression_warning (DECL_SIZE (decl));
03148 else
03149 error_with_decl (decl, "storage size of `%s' isn't constant");
03150 }
03151
03152 if (TREE_USED (type))
03153 TREE_USED (decl) = 1;
03154 }
03155
03156
03157
03158
03159 if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
03160 {
03161 if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
03162 {
03163 tree builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
03164 rtx *libfunc = NULL;
03165 SET_DECL_RTL (builtin, NULL_RTX);
03166 SET_DECL_ASSEMBLER_NAME (builtin, get_identifier (asmspec));
03167 #ifdef TARGET_MEM_FUNCTIONS
03168 if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
03169 init_block_move_fn (asmspec);
03170 else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
03171 init_block_clear_fn (asmspec);
03172 #else
03173 if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BCOPY)
03174 init_block_move_fn (asmspec);
03175 else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BZERO)
03176 init_block_clear_fn (asmspec);
03177 #endif
03178 switch (DECL_FUNCTION_CODE (decl))
03179 {
03180 case BUILT_IN_MEMCPY: libfunc = &memcpy_libfunc; break;
03181 case BUILT_IN_MEMMOVE: libfunc = &memmove_libfunc; break;
03182 case BUILT_IN_BCOPY: libfunc = &bcopy_libfunc; break;
03183 case BUILT_IN_MEMCMP: libfunc = &memcmp_libfunc; break;
03184 case BUILT_IN_MEMSET: libfunc = &memset_libfunc; break;
03185 case BUILT_IN_BZERO: libfunc = &bzero_libfunc; break;
03186 default: break;
03187 }
03188 if (libfunc)
03189 *libfunc = XEXP (DECL_RTL (builtin), 0);
03190 }
03191 SET_DECL_RTL (decl, NULL_RTX);
03192 SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
03193 }
03194
03195
03196
03197
03198
03199 if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
03200 {
03201
03202 if (flag_objc)
03203 objc_check_decl (decl);
03204
03205 if (!DECL_CONTEXT (decl))
03206 {
03207 if (DECL_INITIAL (decl) == NULL_TREE
03208 || DECL_INITIAL (decl) == error_mark_node)
03209
03210
03211
03212 DECL_DEFER_OUTPUT (decl) = 1;
03213 rest_of_decl_compilation (decl, asmspec,
03214 (DECL_CONTEXT (decl) == 0
03215 || TREE_ASM_WRITTEN (decl)), 0);
03216 }
03217 else
03218 {
03219
03220
03221 if (asmspec)
03222 {
03223
03224
03225
03226 if (DECL_REGISTER (decl))
03227 DECL_C_HARD_REGISTER (decl) = 1;
03228
03229
03230
03231
03232
03233
03234 if (TREE_CODE (decl) == VAR_DECL
03235 && !DECL_REGISTER (decl)
03236 && !TREE_STATIC (decl))
03237 warning_with_decl (decl,
03238 "ignoring asm-specifier for non-static local variable `%s'");
03239 else
03240 SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
03241 }
03242
03243 if (TREE_CODE (decl) != FUNCTION_DECL)
03244 add_decl_stmt (decl);
03245 }
03246
03247 if (DECL_CONTEXT (decl) != 0)
03248 {
03249
03250
03251 if (was_incomplete
03252 && ! TREE_STATIC (decl) && ! DECL_EXTERNAL (decl))
03253 {
03254
03255 TREE_ADDRESSABLE (decl) = TREE_USED (decl);
03256
03257 if (DECL_SIZE (decl) == 0)
03258 DECL_INITIAL (decl) = 0;
03259 }
03260 }
03261 }
03262
03263 #ifdef SGI_MONGOOSE
03264 if (TREE_CODE (decl) != FUNCTION_DECL
03265 && TREE_CODE (decl) != PARM_DECL
03266 && DECL_INITIAL (decl) != 0
03267 && DECL_INITIAL (decl) != error_mark_node)
03268 {
03269 dump_parse_tree ("c-decl init", decl);
03270 WFE_Initialize_Decl (decl);
03271 }
03272 #endif
03273
03274 if (TREE_CODE (decl) == TYPE_DECL)
03275 {
03276
03277 if (flag_objc)
03278 objc_check_decl (decl);
03279 rest_of_decl_compilation (decl, NULL, DECL_CONTEXT (decl) == 0, 0);
03280 }
03281
03282 #ifdef KEY
03283 if (TREE_CODE (decl) == VAR_DECL)
03284 TYPE_DEFER_EXPANSION (TREE_TYPE (decl)) = 1;
03285 #endif
03286
03287 #ifdef SGI_MONGOOSE
03288 WFE_Decl (decl);
03289 #endif
03290
03291 #ifdef KEY
03292 if (TREE_CODE (decl) == VAR_DECL)
03293 TYPE_DEFER_EXPANSION (TREE_TYPE (decl)) = 0;
03294 #endif
03295
03296
03297
03298
03299 if (current_binding_level == global_binding_level)
03300 get_pending_sizes ();
03301
03302
03303 if (TREE_CODE (decl) == VAR_DECL && !TREE_STATIC (decl))
03304 {
03305 tree attr = lookup_attribute ("cleanup", DECL_ATTRIBUTES (decl));
03306 if (attr)
03307 {
03308 static bool eh_initialized_p;
03309
03310 tree cleanup_id = TREE_VALUE (TREE_VALUE (attr));
03311 tree cleanup_decl = lookup_name (cleanup_id);
03312 tree cleanup;
03313
03314
03315 cleanup = build_unary_op (ADDR_EXPR, decl, 0);
03316 cleanup = build_tree_list (NULL_TREE, cleanup);
03317 cleanup = build_function_call (cleanup_decl, cleanup);
03318
03319
03320 TREE_USED (decl) = 1;
03321
03322
03323 if (flag_exceptions && !eh_initialized_p)
03324 {
03325 eh_initialized_p = true;
03326 eh_personality_libfunc
03327 = init_one_libfunc (USING_SJLJ_EXCEPTIONS
03328 ? "__gcc_personality_sj0"
03329 : "__gcc_personality_v0");
03330 using_eh_for_cleanups ();
03331 }
03332
03333 add_stmt (build_stmt (CLEANUP_STMT, decl, cleanup));
03334 }
03335 }
03336 }
03337
03338
03339
03340
03341
03342
03343 void
03344 push_parm_decl (parm)
03345 tree parm;
03346 {
03347 tree decl;
03348 int old_immediate_size_expand = immediate_size_expand;
03349
03350 immediate_size_expand = 0;
03351
03352 decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)),
03353 TREE_PURPOSE (TREE_PURPOSE (parm)), PARM, 0);
03354 decl_attributes (&decl, TREE_VALUE (parm), 0);
03355
03356 #if 0
03357 if (DECL_NAME (decl))
03358 {
03359 tree olddecl;
03360 olddecl = lookup_name (DECL_NAME (decl));
03361 if (pedantic && olddecl != 0 && TREE_CODE (olddecl) == TYPE_DECL)
03362 pedwarn_with_decl (decl,
03363 "ISO C forbids parameter `%s' shadowing typedef");
03364 }
03365 #endif
03366
03367 decl = pushdecl (decl);
03368
03369 immediate_size_expand = old_immediate_size_expand;
03370
03371 current_binding_level->parm_order
03372 = tree_cons (NULL_TREE, decl, current_binding_level->parm_order);
03373
03374
03375 finish_decl (decl, NULL_TREE, NULL_TREE);
03376 }
03377
03378
03379
03380
03381
03382 void
03383 clear_parm_order ()
03384 {
03385 current_binding_level->parm_order = NULL_TREE;
03386 }
03387
03388
03389
03390
03391
03392
03393 tree
03394 build_compound_literal (type, init)
03395 tree type;
03396 tree init;
03397 {
03398
03399
03400
03401 tree decl = build_decl (VAR_DECL, NULL_TREE, type);
03402 tree complit;
03403 tree stmt;
03404 DECL_EXTERNAL (decl) = 0;
03405 TREE_PUBLIC (decl) = 0;
03406 TREE_STATIC (decl) = (current_binding_level == global_binding_level);
03407 DECL_CONTEXT (decl) = current_function_decl;
03408 TREE_USED (decl) = 1;
03409 TREE_TYPE (decl) = type;
03410 TREE_READONLY (decl) = TREE_READONLY (type);
03411 store_init_value (decl, init);
03412
03413 if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
03414 {
03415 int failure = complete_array_type (type, DECL_INITIAL (decl), 1);
03416 if (failure)
03417 abort ();
03418 }
03419
03420 type = TREE_TYPE (decl);
03421 if (type == error_mark_node || !COMPLETE_TYPE_P (type))
03422 return error_mark_node;
03423
03424 stmt = build_stmt (DECL_STMT, decl);
03425 complit = build1 (COMPOUND_LITERAL_EXPR, TREE_TYPE (decl), stmt);
03426 TREE_SIDE_EFFECTS (complit) = 1;
03427
03428 layout_decl (decl, 0);
03429
03430 if (TREE_STATIC (decl))
03431 {
03432
03433
03434 char *name;
03435 extern int var_labelno;
03436
03437 ASM_FORMAT_PRIVATE_NAME (name, "__compound_literal", var_labelno);
03438 var_labelno++;
03439 DECL_NAME (decl) = get_identifier (name);
03440 DECL_DEFER_OUTPUT (decl) = 1;
03441 DECL_COMDAT (decl) = 1;
03442 DECL_ARTIFICIAL (decl) = 1;
03443 pushdecl (decl);
03444 rest_of_decl_compilation (decl, NULL, 1, 0);
03445 }
03446
03447 return complit;
03448 }
03449
03450
03451
03452
03453
03454 int
03455 complete_array_type (type, initial_value, do_default)
03456 tree type;
03457 tree initial_value;
03458 int do_default;
03459 {
03460 tree maxindex = NULL_TREE;
03461 int value = 0;
03462
03463 if (initial_value)
03464 {
03465
03466
03467 if (TREE_CODE (initial_value) == STRING_CST)
03468 {
03469 int eltsize
03470 = int_size_in_bytes (TREE_TYPE (TREE_TYPE (initial_value)));
03471 maxindex = build_int_2 ((TREE_STRING_LENGTH (initial_value)
03472 / eltsize) - 1, 0);
03473 }
03474 else if (TREE_CODE (initial_value) == CONSTRUCTOR)
03475 {
03476 tree elts = CONSTRUCTOR_ELTS (initial_value);
03477 maxindex = build_int_2 (-1, -1);
03478 for (; elts; elts = TREE_CHAIN (elts))
03479 {
03480 if (TREE_PURPOSE (elts))
03481 maxindex = TREE_PURPOSE (elts);
03482 else
03483 maxindex = fold (build (PLUS_EXPR, integer_type_node,
03484 maxindex, integer_one_node));
03485 }
03486 maxindex = copy_node (maxindex);
03487 }
03488 else
03489 {
03490
03491 if (initial_value != error_mark_node)
03492 value = 1;
03493
03494
03495 maxindex = build_int_2 (0, 0);
03496 }
03497 }
03498
03499 if (!maxindex)
03500 {
03501 if (do_default)
03502 maxindex = build_int_2 (0, 0);
03503 value = 2;
03504 }
03505
03506 if (maxindex)
03507 {
03508 TYPE_DOMAIN (type) = build_index_type (maxindex);
03509 if (!TREE_TYPE (maxindex))
03510 TREE_TYPE (maxindex) = TYPE_DOMAIN (type);
03511 }
03512
03513
03514
03515 layout_type (type);
03516
03517 return value;
03518 }
03519
03520
03521
03522
03523 static bool
03524 flexible_array_type_p (type)
03525 tree type;
03526 {
03527 tree x;
03528 switch (TREE_CODE (type))
03529 {
03530 case RECORD_TYPE:
03531 x = TYPE_FIELDS (type);
03532 if (x == NULL_TREE)
03533 return false;
03534 while (TREE_CHAIN (x) != NULL_TREE)
03535 x = TREE_CHAIN (x);
03536 if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
03537 && TYPE_SIZE (TREE_TYPE (x)) == NULL_TREE
03538 && TYPE_DOMAIN (TREE_TYPE (x)) != NULL_TREE
03539 && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE)
03540 return true;
03541 return false;
03542 case UNION_TYPE:
03543 for (x = TYPE_FIELDS (type); x != NULL_TREE; x = TREE_CHAIN (x))
03544 {
03545 if (flexible_array_type_p (TREE_TYPE (x)))
03546 return true;
03547 }
03548 return false;
03549 default:
03550 return false;
03551 }
03552 }
03553
03554
03555
03556
03557
03558
03559
03560
03561
03562
03563
03564
03565
03566
03567
03568
03569
03570
03571
03572
03573
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583 static tree
03584 grokdeclarator (declarator, declspecs, decl_context, initialized)
03585 tree declspecs;
03586 tree declarator;
03587 enum decl_context decl_context;
03588 int initialized;
03589 {
03590 int specbits = 0;
03591 tree spec;
03592 tree type = NULL_TREE;
03593 int longlong = 0;
03594 int constp;
03595 int restrictp;
03596 int volatilep;
03597 int type_quals = TYPE_UNQUALIFIED;
03598 int inlinep;
03599 int explicit_int = 0;
03600 int explicit_char = 0;
03601 int defaulted_int = 0;
03602 #if defined(TARG_SL)
03603 int sbufp = 0;
03604 int sdramp = 0;
03605 int v1bufp = 0;
03606 int v2bufp = 0;
03607 int v4bufp = 0;
03608 int vbuf_type = 0;
03609 int internal_mem = 0;
03610 #endif // TARG_SL
03611 tree typedef_decl = 0;
03612 const char *name;
03613 tree typedef_type = 0;
03614 int funcdef_flag = 0;
03615 enum tree_code innermost_code = ERROR_MARK;
03616 int bitfield = 0;
03617 int size_varies = 0;
03618 tree decl_attr = NULL_TREE;
03619 tree array_ptr_quals = NULL_TREE;
03620 int array_parm_static = 0;
03621 tree returned_attrs = NULL_TREE;
03622
03623 if (decl_context == BITFIELD)
03624 bitfield = 1, decl_context = FIELD;
03625
03626 if (decl_context == FUNCDEF)
03627 funcdef_flag = 1, decl_context = NORMAL;
03628
03629
03630
03631 {
03632 tree decl = declarator;
03633 name = 0;
03634
03635 while (decl)
03636 switch (TREE_CODE (decl))
03637 {
03638 case ARRAY_REF:
03639 case INDIRECT_REF:
03640 case CALL_EXPR:
03641 innermost_code = TREE_CODE (decl);
03642 decl = TREE_OPERAND (decl, 0);
03643 break;
03644
03645 case TREE_LIST:
03646 decl = TREE_VALUE (decl);
03647 break;
03648
03649 case IDENTIFIER_NODE:
03650 name = IDENTIFIER_POINTER (decl);
03651 decl = 0;
03652 break;
03653
03654 default:
03655 abort ();
03656 }
03657 if (name == 0)
03658 name = "type name";
03659 }
03660
03661
03662
03663
03664 if (funcdef_flag && innermost_code != CALL_EXPR)
03665 return 0;
03666
03667
03668
03669
03670
03671
03672
03673
03674 if (decl_context == NORMAL && !funcdef_flag
03675 && current_binding_level->parm_flag)
03676 decl_context = PARM;
03677
03678
03679
03680
03681
03682
03683
03684
03685
03686
03687
03688
03689
03690
03691
03692 for (spec = declspecs; spec; spec = TREE_CHAIN (spec))
03693 {
03694 tree id = TREE_VALUE (spec);
03695
03696
03697
03698 if (id && TREE_DEPRECATED (id))
03699 {
03700 if (deprecated_state != DEPRECATED_SUPPRESS)
03701 warn_deprecated_use (id);
03702 }
03703
03704 if (id == ridpointers[(int) RID_INT])
03705 explicit_int = 1;
03706 if (id == ridpointers[(int) RID_CHAR])
03707 explicit_char = 1;
03708
03709 if (TREE_CODE (id) == IDENTIFIER_NODE && C_IS_RESERVED_WORD (id))
03710 {
03711 enum rid i = C_RID_CODE (id);
03712 if ((int) i <= (int) RID_LAST_MODIFIER)
03713 {
03714 #if defined(TARG_SL)
03715
03716
03717
03718 {
03719 switch(i) {
03720 case RID_V1BUF:
03721 case RID_V2BUF:
03722 case RID_V4BUF:
03723 vbuf_type = 1;
03724
03725 case RID_SBUF:
03726 case RID_SDRAM:
03727 internal_mem = i;
03728 break;
03729 default:
03730 break;
03731 }
03732 }
03733 #endif // TARG_SL
03734 if (i == RID_LONG && (specbits & (1 << (int) RID_LONG)))
03735 {
03736 if (longlong)
03737 error ("`long long long' is too long for GCC");
03738 else
03739 {
03740 if (pedantic && !flag_isoc99 && ! in_system_header
03741 && warn_long_long)
03742 pedwarn ("ISO C90 does not support `long long'");
03743 longlong = 1;
03744 }
03745 }
03746 else if (specbits & (1 << (int) i))
03747 {
03748 if (i == RID_CONST || i == RID_VOLATILE || i == RID_RESTRICT)
03749 {
03750 if (!flag_isoc99)
03751 pedwarn ("duplicate `%s'", IDENTIFIER_POINTER (id));
03752 }
03753 else
03754 error ("duplicate `%s'", IDENTIFIER_POINTER (id));
03755 }
03756
03757
03758
03759 if (i == RID_THREAD
03760 && (specbits & (1 << (int) RID_EXTERN
03761 | 1 << (int) RID_STATIC)))
03762 {
03763 if (specbits & 1 << (int) RID_EXTERN)
03764 error ("`__thread' before `extern'");
03765 else
03766 error ("`__thread' before `static'");
03767 }
03768
03769 specbits |= 1 << (int) i;
03770 goto found;
03771 }
03772 }
03773 if (type)
03774 error ("two or more data types in declaration of `%s'", name);
03775
03776 else if (TREE_CODE (id) == TYPE_DECL)
03777 {
03778 if (TREE_TYPE (id) == error_mark_node)
03779 ;
03780 else
03781 {
03782 type = TREE_TYPE (id);
03783 decl_attr = DECL_ATTRIBUTES (id);
03784 typedef_decl = id;
03785 }
03786 }
03787
03788 else if (TREE_CODE (id) == IDENTIFIER_NODE)
03789 {
03790 tree t = lookup_name (id);
03791 if (TREE_TYPE (t) == error_mark_node)
03792 ;
03793 else if (!t || TREE_CODE (t) != TYPE_DECL)
03794 error ("`%s' fails to be a typedef or built in type",
03795 IDENTIFIER_POINTER (id));
03796 else
03797 {
03798 type = TREE_TYPE (t);
03799 typedef_decl = t;
03800 }
03801 }
03802 else if (TREE_CODE (id) != ERROR_MARK)
03803 type = id;
03804
03805 found:
03806 ;
03807 }
03808
03809 typedef_type = type;
03810 if (type)
03811 size_varies = C_TYPE_VARIABLE_SIZE (type);
03812
03813
03814
03815
03816 if (type == 0)
03817 {
03818 if ((! (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
03819 | (1 << (int) RID_SIGNED)
03820 | (1 << (int) RID_UNSIGNED)
03821 | (1 << (int) RID_COMPLEX))))
03822
03823 && ! (specbits & (1 << (int) RID_TYPEDEF) && initialized)
03824 && ! in_system_header)
03825 {
03826
03827
03828
03829 if ((warn_implicit_int || warn_return_type || flag_isoc99)
03830 && funcdef_flag)
03831 warn_about_return_type = 1;
03832 else if (warn_implicit_int || flag_isoc99)
03833 pedwarn_c99 ("type defaults to `int' in declaration of `%s'",
03834 name);
03835 }
03836
03837 #if defined(TARG_SL)
03838
03839 if( vbuf_type ) {
03840 type = char_type_node;
03841 }
03842 else {
03843 #endif // TARG_SL
03844 defaulted_int = 1;
03845 type = integer_type_node;
03846 }
03847 #if defined(TARG_SL)
03848 }
03849 #endif
03850
03851
03852
03853
03854
03855
03856 if ((specbits & 1 << (int) RID_LONG) && ! longlong
03857 && TYPE_MAIN_VARIANT (type) == double_type_node)
03858 {
03859 specbits &= ~(1 << (int) RID_LONG);
03860 type = long_double_type_node;
03861 }
03862
03863 #ifdef TARG_SL
03864 if (TREE_CODE(type) == REAL_TYPE)
03865 {
03866 if (TYPE_MAIN_VARIANT(type) == double_type_node || TYPE_MAIN_VARIANT(type) == float_type_node)
03867 {
03868 if (Float_Point_Support == FALSE)
03869 {
03870 error("\"float/double\" type is not supported in default mode, "
03871 "Please use \"-msoft-float\" option to enable float point emulation");
03872 }
03873 }
03874 else
03875 {
03876 warning("Unsupported real type\n");
03877 }
03878 }
03879 #endif
03880
03881
03882
03883 if (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
03884 | (1 << (int) RID_UNSIGNED) | (1 << (int) RID_SIGNED)))
03885 {
03886 int ok = 0;
03887
03888 if ((specbits & 1 << (int) RID_LONG)
03889 && (specbits & 1 << (int) RID_SHORT))
03890 error ("both long and short specified for `%s'", name);
03891 else if (((specbits & 1 << (int) RID_LONG)
03892 || (specbits & 1 << (int) RID_SHORT))
03893 && explicit_char)
03894 error ("long or short specified with char for `%s'", name);
03895 else if (((specbits & 1 << (int) RID_LONG)
03896 || (specbits & 1 << (int) RID_SHORT))
03897 && TREE_CODE (type) == REAL_TYPE)
03898 {
03899 static int already = 0;
03900
03901 error ("long or short specified with floating type for `%s'", name);
03902 if (! already && ! pedantic)
03903 {
03904 error ("the only valid combination is `long double'");
03905 already = 1;
03906 }
03907 }
03908 else if ((specbits & 1 << (int) RID_SIGNED)
03909 && (specbits & 1 << (int) RID_UNSIGNED))
03910 error ("both signed and unsigned specified for `%s'", name);
03911 else if (TREE_CODE (type) != INTEGER_TYPE)
03912 error ("long, short, signed or unsigned invalid for `%s'", name);
03913 else
03914 {
03915 ok = 1;
03916 if (!explicit_int && !defaulted_int && !explicit_char)
03917 {
03918 error ("long, short, signed or unsigned used invalidly for `%s'",
03919 name);
03920 ok = 0;
03921 }
03922 }
03923
03924
03925 if (! ok)
03926 {
03927 specbits &= ~((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
03928 | (1 << (int) RID_UNSIGNED) | (1 << (int) RID_SIGNED));
03929 longlong = 0;
03930 }
03931 }
03932
03933 if ((specbits & (1 << (int) RID_COMPLEX))
03934 && TREE_CODE (type) != INTEGER_TYPE && TREE_CODE (type) != REAL_TYPE)
03935 {
03936 error ("complex invalid for `%s'", name);
03937 specbits &= ~(1 << (int) RID_COMPLEX);
03938 }
03939
03940
03941
03942 if (specbits & 1 << (int) RID_UNSIGNED
03943 || (bitfield && ! flag_signed_bitfields
03944 && (explicit_int || defaulted_int || explicit_char
03945
03946
03947 || ! (typedef_decl != 0
03948 && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
03949 && TREE_CODE (type) != ENUMERAL_TYPE
03950 && !(specbits & 1 << (int) RID_SIGNED)))
03951 {
03952 if (longlong)
03953 {
03954 #ifdef TARG_SL
03955 if (Long_Long_Support == TRUE)
03956 {
03957 type = long_long_unsigned_type_node;
03958 }
03959 else
03960 {
03961 warning("\"unsigned long long\" is mapped to \"unsigned long\" in declaration %s, "
03962 "Please use \"-mlong-long\" option to enbale long long type suporting", name);
03963 type = long_unsigned_type_node;
03964 }
03965 #else
03966 type = long_long_unsigned_type_node;
03967 #endif
03968 }
03969 else if (specbits & 1 << (int) RID_LONG)
03970 type = long_unsigned_type_node;
03971 else if (specbits & 1 << (int) RID_SHORT)
03972 type = short_unsigned_type_node;
03973 else if (type == char_type_node)
03974 type = unsigned_char_type_node;
03975 else if (typedef_decl)
03976 type = c_common_unsigned_type (type);
03977 else
03978 type = unsigned_type_node;
03979 }
03980 else if ((specbits & 1 << (int) RID_SIGNED)
03981 && type == char_type_node)
03982 type = signed_char_type_node;
03983 else if (longlong)
03984 {
03985 #ifdef TARG_SL
03986 if (Long_Long_Support == TRUE)
03987 {
03988 type = long_long_integer_type_node;
03989 }
03990 else
03991 {
03992 warning("\"long long\" is mapped to \"long\" in declaration %s, "
03993 "Please use \"-mlong-long\" option to enbale long long type supporting", name);
03994 type = long_integer_type_node;
03995 }
03996 #else
03997 type = long_long_integer_type_node;
03998 #endif
03999 }
04000 else if (specbits & 1 << (int) RID_LONG)
04001 type = long_integer_type_node;
04002 else if (specbits & 1 << (int) RID_SHORT)
04003 type = short_integer_type_node;
04004
04005 if (specbits & 1 << (int) RID_COMPLEX)
04006 {
04007 #ifdef TARG_SL
04008 error("Unsupported type: \"complex\"");
04009 #endif
04010 if (pedantic && !flag_isoc99)
04011 pedwarn ("ISO C90 does not support complex types");
04012
04013
04014
04015
04016
04017 if (defaulted_int && ! longlong
04018 && ! (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
04019 | (1 << (int) RID_SIGNED)
04020 | (1 << (int) RID_UNSIGNED))))
04021 {
04022 if (pedantic)
04023 pedwarn ("ISO C does not support plain `complex' meaning `double complex'");
04024 type = complex_double_type_node;
04025 }
04026 else if (type == integer_type_node)
04027 {
04028 if (pedantic)
04029 pedwarn ("ISO C does not support complex integer types");
04030 type = complex_integer_type_node;
04031 }
04032 else if (type == float_type_node)
04033 type = complex_float_type_node;
04034 else if (type == double_type_node)
04035 type = complex_double_type_node;
04036 else if (type == long_double_type_node)
04037 type = complex_long_double_type_node;
04038 else
04039 {
04040 if (pedantic)
04041 pedwarn ("ISO C does not support complex integer types");
04042 type = build_complex_type (type);
04043 }
04044 }
04045
04046
04047
04048
04049
04050
04051 constp = !! (specbits & 1 << (int) RID_CONST) + TYPE_READONLY (type);
04052 restrictp = !! (specbits & 1 << (int) RID_RESTRICT) + TYPE_RESTRICT (type);
04053 volatilep = !! (specbits & 1 << (int) RID_VOLATILE) + TYPE_VOLATILE (type);
04054 inlinep = !! (specbits & (1 << (int) RID_INLINE));
04055 #if defined(TARG_SL)
04056 sbufp = !! (specbits & (1 << (int) RID_SBUF));
04057 sdramp =!! (specbits & (1 << (int) RID_SDRAM));
04058 v1bufp = !! (specbits & (1 << (int) RID_V1BUF));
04059 v2bufp = !! (specbits & (1 << (int) RID_V2BUF));
04060 v4bufp = !! (specbits & (1 << (int) RID_V4BUF));
04061 #endif // TARG_SL
04062 if (constp > 1 && ! flag_isoc99)
04063 pedwarn ("duplicate `const'");
04064 if (restrictp > 1 && ! flag_isoc99)
04065 pedwarn ("duplicate `restrict'");
04066 if (volatilep > 1 && ! flag_isoc99)
04067 pedwarn ("duplicate `volatile'");
04068 if (! flag_gen_aux_info && (TYPE_QUALS (type)))
04069 type = TYPE_MAIN_VARIANT (type);
04070 type_quals = ((constp ? TYPE_QUAL_CONST : 0)
04071 | (restrictp ? TYPE_QUAL_RESTRICT : 0)
04072 | (volatilep ? TYPE_QUAL_VOLATILE : 0)
04073 #if defined(TARG_SL)
04074 | (sbufp ? TYPE_QUAL_SBUF : 0)
04075 | (sdramp ? TYPE_QUAL_SDRAM : 0)
04076 | (v1bufp ? TYPE_QUAL_V1BUF : 0)
04077 | (v2bufp ? TYPE_QUAL_V2BUF : 0)
04078 | (v4bufp ? TYPE_QUAL_V4BUF : 0)
04079 #endif
04080 );
04081
04082
04083
04084 {
04085 int nclasses = 0;
04086
04087 if (specbits & 1 << (int) RID_AUTO) nclasses++;
04088 if (specbits & 1 << (int) RID_STATIC) nclasses++;
04089 if (specbits & 1 << (int) RID_EXTERN) nclasses++;
04090 if (specbits & 1 << (int) RID_REGISTER) nclasses++;
04091 if (specbits & 1 << (int) RID_TYPEDEF) nclasses++;
04092
04093
04094 if ((specbits & (1 << (int) RID_THREAD
04095 | 1 << (int) RID_STATIC
04096 | 1 << (int) RID_EXTERN)) == (1 << (int) RID_THREAD))
04097 nclasses++;
04098
04099
04100
04101
04102 if (nclasses > 1)
04103 error ("multiple storage classes in declaration of `%s'", name);
04104 else if (funcdef_flag
04105 && (specbits
04106 & ((1 << (int) RID_REGISTER)
04107 | (1 << (int) RID_AUTO)
04108 | (1 << (int) RID_TYPEDEF)
04109 | (1 << (int) RID_THREAD))))
04110 {
04111 if (specbits & 1 << (int) RID_AUTO
04112 && (pedantic || current_binding_level == global_binding_level))
04113 pedwarn ("function definition declared `auto'");
04114 if (specbits & 1 << (int) RID_REGISTER)
04115 error ("function definition declared `register'");
04116 if (specbits & 1 << (int) RID_TYPEDEF)
04117 error ("function definition declared `typedef'");
04118 if (specbits & 1 << (int) RID_THREAD)
04119 error ("function definition declared `__thread'");
04120 specbits &= ~((1 << (int) RID_TYPEDEF) | (1 << (int) RID_REGISTER)
04121 | (1 << (int) RID_AUTO) | (1 << (int) RID_THREAD));
04122 }
04123 else if (decl_context != NORMAL && nclasses > 0)
04124 {
04125 if (decl_context == PARM && specbits & 1 << (int) RID_REGISTER)
04126 ;
04127 else
04128 {
04129 switch (decl_context)
04130 {
04131 case FIELD:
04132 error ("storage class specified for structure field `%s'",
04133 name);
04134 break;
04135 case PARM:
04136 error ("storage class specified for parameter `%s'", name);
04137 break;
04138 default:
04139 error ("storage class specified for typename");
04140 break;
04141 }
04142 specbits &= ~((1 << (int) RID_TYPEDEF) | (1 << (int) RID_REGISTER)
04143 | (1 << (int) RID_AUTO) | (1 << (int) RID_STATIC)
04144 | (1 << (int) RID_EXTERN) | (1 << (int) RID_THREAD));
04145 }
04146 }
04147 else if (specbits & 1 << (int) RID_EXTERN && initialized && ! funcdef_flag)
04148 {
04149
04150 if (current_binding_level == global_binding_level)
04151 warning ("`%s' initialized and declared `extern'", name);
04152 else
04153 error ("`%s' has both `extern' and initializer", name);
04154 }
04155 else if (current_binding_level == global_binding_level)
04156 {
04157 if (specbits & 1 << (int) RID_AUTO)
04158 error ("top-level declaration of `%s' specifies `auto'", name);
04159 }
04160 else
04161 {
04162 if (specbits & 1 << (int) RID_EXTERN && funcdef_flag)
04163 error ("nested function `%s' declared `extern'", name);
04164 else if ((specbits & (1 << (int) RID_THREAD
04165 | 1 << (int) RID_EXTERN
04166 | 1 << (int) RID_STATIC))
04167 == (1 << (int) RID_THREAD))
04168 {
04169 error ("function-scope `%s' implicitly auto and declared `__thread'",
04170 name);
04171 specbits &= ~(1 << (int) RID_THREAD);
04172 }
04173 }
04174 }
04175
04176
04177
04178
04179
04180 while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE)
04181 {
04182 if (type == error_mark_node)
04183 {
04184 declarator = TREE_OPERAND (declarator, 0);
04185 continue;
04186 }
04187
04188
04189
04190
04191
04192
04193
04194
04195
04196
04197
04198
04199
04200
04201
04202
04203 if (array_ptr_quals != NULL_TREE || array_parm_static)
04204 {
04205
04206
04207
04208 error ("static or type qualifiers in non-parameter array declarator");
04209 array_ptr_quals = NULL_TREE;
04210 array_parm_static = 0;
04211 }
04212
04213 if (TREE_CODE (declarator) == TREE_LIST)
04214 {
04215
04216
04217 tree attrs = TREE_PURPOSE (declarator);
04218 tree inner_decl;
04219 int attr_flags = 0;
04220 declarator = TREE_VALUE (declarator);
04221 inner_decl = declarator;
04222 while (inner_decl != NULL_TREE
04223 && TREE_CODE (inner_decl) == TREE_LIST)
04224 inner_decl = TREE_VALUE (inner_decl);
04225 if (inner_decl == NULL_TREE
04226 || TREE_CODE (inner_decl) == IDENTIFIER_NODE)
04227 attr_flags |= (int) ATTR_FLAG_DECL_NEXT;
04228 else if (TREE_CODE (inner_decl) == CALL_EXPR)
04229 attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT;
04230 else if (TREE_CODE (inner_decl) == ARRAY_REF)
04231 attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT;
04232 returned_attrs = decl_attributes (&type,
04233 chainon (returned_attrs, attrs),
04234 attr_flags);
04235 }
04236 else if (TREE_CODE (declarator) == ARRAY_REF)
04237 {
04238 tree itype = NULL_TREE;
04239 tree size = TREE_OPERAND (declarator, 1);
04240
04241 tree index_type = c_common_signed_type (sizetype);
04242
04243 array_ptr_quals = TREE_TYPE (declarator);
04244 array_parm_static = TREE_STATIC (declarator);
04245
04246 declarator = TREE_OPERAND (declarator, 0);
04247
04248
04249
04250 if (VOID_TYPE_P (type))
04251 {
04252 error ("declaration of `%s' as array of voids", name);
04253 type = error_mark_node;
04254 }
04255
04256 if (TREE_CODE (type) == FUNCTION_TYPE)
04257 {
04258 error ("declaration of `%s' as array of functions", name);
04259 type = error_mark_node;
04260 }
04261
04262 if (pedantic && flexible_array_type_p (type))
04263 pedwarn ("invalid use of structure with flexible array member");
04264
04265 if (size == error_mark_node)
04266 type = error_mark_node;
04267
04268 if (type == error_mark_node)
04269 continue;
04270
04271
04272
04273
04274
04275 if (size)
04276 {
04277
04278 STRIP_TYPE_NOPS (size);
04279
04280 if (! INTEGRAL_TYPE_P (TREE_TYPE (size)))
04281 {
04282 error ("size of array `%s' has non-integer type", name);
04283 size = integer_one_node;
04284 }
04285
04286 if (pedantic && integer_zerop (size))
04287 pedwarn ("ISO C forbids zero-size array `%s'", name);
04288
04289 if (TREE_CODE (size) == INTEGER_CST)
04290 {
04291 constant_expression_warning (size);
04292 if (tree_int_cst_sgn (size) < 0)
04293 {
04294 error ("size of array `%s' is negative", name);
04295 size = integer_one_node;
04296 }
04297 }
04298 else
04299 {
04300
04301
04302 size_varies = 1;
04303
04304 if (!flag_isoc99 && pedantic)
04305 {
04306 if (TREE_CONSTANT (size))
04307 pedwarn ("ISO C90 forbids array `%s' whose size can't be evaluated",
04308 name);
04309 else
04310 pedwarn ("ISO C90 forbids variable-size array `%s'",
04311 name);
04312 }
04313 }
04314
04315 if (integer_zerop (size))
04316 {
04317
04318
04319
04320 itype = build_range_type (sizetype, size, NULL_TREE);
04321 }
04322 else
04323 {
04324
04325
04326
04327
04328 itype = fold (build (MINUS_EXPR, index_type,
04329 convert (index_type, size),
04330 convert (index_type, size_one_node)));
04331
04332
04333
04334
04335
04336
04337
04338 if (TREE_OVERFLOW (itype))
04339 {
04340 error ("size of array `%s' is too large", name);
04341 type = error_mark_node;
04342 continue;
04343 }
04344
04345 if (size_varies)
04346 {
04347
04348
04349
04350
04351
04352
04353 tree cfd = current_function_decl;
04354 if (decl_context == PARM)
04355 current_function_decl = NULL_TREE;
04356 itype = variable_size (itype);
04357 if (decl_context == PARM)
04358 current_function_decl = cfd;
04359 }
04360 itype = build_index_type (itype);
04361 }
04362 }
04363 else if (decl_context == FIELD)
04364 {
04365 if (pedantic && !flag_isoc99 && !in_system_header)
04366 pedwarn ("ISO C90 does not support flexible array members");
04367
04368
04369
04370 itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
04371 }
04372
04373
04374
04375 if (pedantic && !COMPLETE_TYPE_P (type))
04376 pedwarn ("array type has incomplete element type");
04377
04378 #if 0
04379
04380
04381 if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
04382 && (constp || volatilep))
04383 pedwarn ("ISO C forbids const or volatile function types");
04384 #endif
04385
04386
04387
04388
04389
04390
04391 type = build_array_type (type, itype);
04392 if (type_quals)
04393 type = c_build_qualified_type (type, type_quals);
04394
04395 if (size_varies)
04396 C_TYPE_VARIABLE_SIZE (type) = 1;
04397
04398
04399
04400 if (size && integer_zerop (size))
04401 {
04402 layout_type (type);
04403 TYPE_SIZE (type) = bitsize_zero_node;
04404 TYPE_SIZE_UNIT (type) = size_zero_node;
04405 }
04406 if (decl_context != PARM
04407 && (array_ptr_quals != NULL_TREE || array_parm_static))
04408 {
04409 error ("static or type qualifiers in non-parameter array declarator");
04410 array_ptr_quals = NULL_TREE;
04411 array_parm_static = 0;
04412 }
04413 }
04414 else if (TREE_CODE (declarator) == CALL_EXPR)
04415 {
04416 tree arg_types;
04417
04418
04419
04420 if (type == error_mark_node)
04421 continue;
04422
04423 size_varies = 0;
04424
04425
04426
04427 if (TREE_CODE (type) == FUNCTION_TYPE)
04428 {
04429 error ("`%s' declared as function returning a function", name);
04430 type = integer_type_node;
04431 }
04432 if (TREE_CODE (type) == ARRAY_TYPE)
04433 {
04434 error ("`%s' declared as function returning an array", name);
04435 type = integer_type_node;
04436 }
04437
04438
04439
04440
04441 arg_types = grokparms (TREE_OPERAND (declarator, 1),
04442 funcdef_flag
04443
04444
04445
04446 && TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE);
04447
04448
04449 if (type_quals)
04450 {
04451
04452
04453
04454
04455
04456
04457
04458
04459
04460
04461 if (VOID_TYPE_P (type) && pedantic && !in_system_header)
04462 pedwarn ("ISO C forbids qualified void function return type");
04463 else if (extra_warnings
04464 && !(VOID_TYPE_P (type)
04465 && type_quals == TYPE_QUAL_VOLATILE))
04466 warning ("type qualifiers ignored on function return type");
04467
04468 type = c_build_qualified_type (type, type_quals);
04469 }
04470 type_quals = TYPE_UNQUALIFIED;
04471
04472 type = build_function_type (type, arg_types);
04473 declarator = TREE_OPERAND (declarator, 0);
04474
04475
04476
04477
04478
04479 {
04480 tree link;
04481
04482 for (link = last_function_parm_tags;
04483 link;
04484 link = TREE_CHAIN (link))
04485 TYPE_CONTEXT (TREE_VALUE (link)) = type;
04486 }
04487 }
04488 else if (TREE_CODE (declarator) == INDIRECT_REF)
04489 {
04490
04491
04492
04493 if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
04494 && type_quals)
04495 pedwarn ("ISO C forbids qualified function types");
04496 if (type_quals)
04497 type = c_build_qualified_type (type, type_quals);
04498 type_quals = TYPE_UNQUALIFIED;
04499 size_varies = 0;
04500
04501 type = build_pointer_type (type);
04502
04503
04504
04505
04506 if (TREE_TYPE (declarator))
04507 {
04508 tree typemodlist;
04509 int erred = 0;
04510
04511 constp = 0;
04512 volatilep = 0;
04513 restrictp = 0;
04514 for (typemodlist = TREE_TYPE (declarator); typemodlist;
04515 typemodlist = TREE_CHAIN (typemodlist))
04516 {
04517 tree qualifier = TREE_VALUE (typemodlist);
04518
04519 if (C_IS_RESERVED_WORD (qualifier))
04520 {
04521 if (C_RID_CODE (qualifier) == RID_CONST)
04522 constp++;
04523 else if (C_RID_CODE (qualifier) == RID_VOLATILE)
04524 volatilep++;
04525 else if (C_RID_CODE (qualifier) == RID_RESTRICT)
04526 restrictp++;
04527 else
04528 erred++;
04529 }
04530 else
04531 erred++;
04532 }
04533
04534 if (erred)
04535 error ("invalid type modifier within pointer declarator");
04536 if (constp > 1 && ! flag_isoc99)
04537 pedwarn ("duplicate `const'");
04538 if (volatilep > 1 && ! flag_isoc99)
04539 pedwarn ("duplicate `volatile'");
04540 if (restrictp > 1 && ! flag_isoc99)
04541 pedwarn ("duplicate `restrict'");
04542
04543 type_quals = ((constp ? TYPE_QUAL_CONST : 0)
04544 | (restrictp ? TYPE_QUAL_RESTRICT : 0)
04545 | (volatilep ? TYPE_QUAL_VOLATILE : 0));
04546 }
04547
04548 declarator = TREE_OPERAND (declarator, 0);
04549 }
04550 else
04551 abort ();
04552
04553 }
04554
04555
04556
04557
04558
04559 if (TREE_CODE (type) == ARRAY_TYPE
04560 && COMPLETE_TYPE_P (type)
04561 && TREE_OVERFLOW (TYPE_SIZE (type)))
04562 {
04563 error ("size of array `%s' is too large", name);
04564
04565
04566 type = error_mark_node;
04567 }
04568
04569
04570
04571 if (specbits & (1 << (int) RID_TYPEDEF))
04572 {
04573 tree decl;
04574
04575
04576 if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
04577 && type_quals)
04578 pedwarn ("ISO C forbids qualified function types");
04579 if (type_quals)
04580 type = c_build_qualified_type (type, type_quals);
04581 decl = build_decl (TYPE_DECL, declarator, type);
04582 if ((specbits & (1 << (int) RID_SIGNED))
04583 || (typedef_decl && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
04584 C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
04585 decl_attributes (&decl, returned_attrs, 0);
04586 return decl;
04587 }
04588
04589
04590
04591
04592
04593
04594
04595 if (type != 0 && typedef_type != 0
04596 && TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == 0
04597 && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (typedef_type))
04598 {
04599 type = build_array_type (TREE_TYPE (type), 0);
04600 if (size_varies)
04601 C_TYPE_VARIABLE_SIZE (type) = 1;
04602 }
04603
04604
04605
04606
04607 if (decl_context == TYPENAME)
04608 {
04609
04610
04611 if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
04612 && type_quals)
04613 pedwarn ("ISO C forbids const or volatile function types");
04614 if (type_quals)
04615 type = c_build_qualified_type (type, type_quals);
04616 decl_attributes (&type, returned_attrs, 0);
04617 return type;
04618 }
04619
04620
04621
04622
04623
04624
04625
04626 if (VOID_TYPE_P (type) && decl_context != PARM
04627 && ! ((decl_context != FIELD && TREE_CODE (type) != FUNCTION_TYPE)
04628 && ((specbits & (1 << (int) RID_EXTERN))
04629 || (current_binding_level == global_binding_level
04630 && !(specbits
04631 & ((1 << (int) RID_STATIC) | (1 << (int) RID_REGISTER)))))))
04632 {
04633 error ("variable or field `%s' declared void", name);
04634 type = integer_type_node;
04635 }
04636
04637
04638
04639
04640 {
04641 tree decl;
04642
04643 if (decl_context == PARM)
04644 {
04645 tree type_as_written;
04646 tree promoted_type;
04647
04648
04649
04650
04651 if (TREE_CODE (type) == ARRAY_TYPE)
04652 {
04653
04654 type = TREE_TYPE (type);
04655 if (type_quals)
04656 type = c_build_qualified_type (type, type_quals);
04657 type = build_pointer_type (type);
04658 type_quals = TYPE_UNQUALIFIED;
04659 if (array_ptr_quals)
04660 {
04661 tree new_ptr_quals, new_ptr_attrs;
04662 int erred = 0;
04663 split_specs_attrs (array_ptr_quals, &new_ptr_quals, &new_ptr_attrs);
04664
04665 if (new_ptr_attrs != NULL_TREE)
04666 warning ("attributes in parameter array declarator ignored");
04667
04668 constp = 0;
04669 volatilep = 0;
04670 restrictp = 0;
04671 for (; new_ptr_quals; new_ptr_quals = TREE_CHAIN (new_ptr_quals))
04672 {
04673 tree qualifier = TREE_VALUE (new_ptr_quals);
04674
04675 if (C_IS_RESERVED_WORD (qualifier))
04676 {
04677 if (C_RID_CODE (qualifier) == RID_CONST)
04678 constp++;
04679 else if (C_RID_CODE (qualifier) == RID_VOLATILE)
04680 volatilep++;
04681 else if (C_RID_CODE (qualifier) == RID_RESTRICT)
04682 restrictp++;
04683 else
04684 erred++;
04685 }
04686 else
04687 erred++;
04688 }
04689
04690 if (erred)
04691 error ("invalid type modifier within array declarator");
04692
04693 type_quals = ((constp ? TYPE_QUAL_CONST : 0)
04694 | (restrictp ? TYPE_QUAL_RESTRICT : 0)
04695 | (volatilep ? TYPE_QUAL_VOLATILE : 0));
04696 }
04697 size_varies = 0;
04698 }
04699 else if (TREE_CODE (type) == FUNCTION_TYPE)
04700 {
04701 if (pedantic && type_quals)
04702 pedwarn ("ISO C forbids qualified function types");
04703 if (type_quals)
04704 type = c_build_qualified_type (type, type_quals);
04705 type = build_pointer_type (type);
04706 type_quals = TYPE_UNQUALIFIED;
04707 }
04708 else if (type_quals)
04709 type = c_build_qualified_type (type, type_quals);
04710
04711 type_as_written = type;
04712
04713 decl = build_decl (PARM_DECL, declarator, type);
04714 if (size_varies)
04715 C_DECL_VARIABLE_SIZE (decl) = 1;
04716
04717
04718
04719
04720
04721
04722 if (type == error_mark_node)
04723 promoted_type = type;
04724 else
04725 promoted_type = c_type_promotes_to (type);
04726
04727 DECL_ARG_TYPE (decl) = promoted_type;
04728 DECL_ARG_TYPE_AS_WRITTEN (decl) = type_as_written;
04729 }
04730 else if (decl_context == FIELD)
04731 {
04732
04733
04734 if (TREE_CODE (type) == FUNCTION_TYPE)
04735 {
04736 error ("field `%s' declared as a function", name);
04737 type = build_pointer_type (type);
04738 }
04739 else if (TREE_CODE (type) != ERROR_MARK
04740 && !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
04741 {
04742 error ("field `%s' has incomplete type", name);
04743 type = error_mark_node;
04744 }
04745
04746 if (TREE_CODE (type) == ARRAY_TYPE && type_quals)
04747 {
04748 type = build_array_type (c_build_qualified_type (TREE_TYPE (type),
04749 type_quals),
04750 TYPE_DOMAIN (type));
04751 #if 0
04752
04753 type_quals = TYPE_UNQUALIFIED;
04754 #endif
04755 }
04756 #if defined(TARG_SL)
04757 else if(internal_mem && TREE_CODE(declarator) == IDENTIFIER_NODE )
04758 {
04759
04760 switch(internal_mem) {
04761 case RID_V1BUF:
04762 type = c_build_qualified_type(type, TYPE_QUAL_V1BUF);
04763 break;
04764 case RID_V2BUF:
04765 type = c_build_qualified_type(type, TYPE_QUAL_V2BUF);
04766 break;
04767 case RID_V4BUF:
04768 type = c_build_qualified_type(type, TYPE_QUAL_V4BUF);
04769 break;
04770 case RID_SBUF:
04771 type = c_build_qualified_type(type, TYPE_QUAL_SBUF);
04772 break;
04773 case RID_SDRAM:
04774 type = c_build_qualified_type(type, TYPE_QUAL_SDRAM);
04775 }
04776 }
04777 #endif // TARG_SL
04778 decl = build_decl (FIELD_DECL, declarator, type);
04779 DECL_NONADDRESSABLE_P (decl) = bitfield;
04780
04781 if (size_varies)
04782 C_DECL_VARIABLE_SIZE (decl) = 1;
04783 }
04784 else if (TREE_CODE (type) == FUNCTION_TYPE)
04785 {
04786
04787
04788
04789
04790
04791 int extern_ref = (!(specbits & (1 << (int) RID_AUTO))
04792 || current_binding_level == global_binding_level);
04793
04794 if (specbits & (1 << (int) RID_AUTO)
04795 && (pedantic || current_binding_level == global_binding_level))
04796 pedwarn ("invalid storage class for function `%s'", name);
04797 if (specbits & (1 << (int) RID_REGISTER))
04798 error ("invalid storage class for function `%s'", name);
04799 if (specbits & (1 << (int) RID_THREAD))
04800 error ("invalid storage class for function `%s'", name);
04801
04802
04803
04804 if (current_binding_level != global_binding_level
04805 && (specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_INLINE)))
04806 && pedantic)
04807 pedwarn ("invalid storage class for function `%s'", name);
04808
04809 decl = build_decl (FUNCTION_DECL, declarator, type);
04810 decl = build_decl_attribute_variant (decl, decl_attr);
04811
04812 DECL_LANG_SPECIFIC (decl) = (struct lang_decl *)
04813 ggc_alloc_cleared (sizeof (struct lang_decl));
04814
04815 if (pedantic && type_quals && ! DECL_IN_SYSTEM_HEADER (decl))
04816 pedwarn ("ISO C forbids qualified function types");
04817
04818
04819
04820 if ((type_quals & TYPE_QUAL_VOLATILE)
04821 && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
04822 warning ("`noreturn' function returns non-void value");
04823
04824 if (extern_ref)
04825 DECL_EXTERNAL (decl) = 1;
04826
04827 TREE_PUBLIC (decl)
04828 = !(specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_AUTO)));
04829
04830 if (defaulted_int)
04831 C_FUNCTION_IMPLICIT_INT (decl) = 1;
04832
04833
04834 if (MAIN_NAME_P (declarator))
04835 {
04836 if (inlinep)
04837 warning ("cannot inline function `main'");
04838 }
04839 else if (inlinep)
04840 {
04841
04842 DECL_DECLARED_INLINE_P (decl) = 1;
04843
04844
04845
04846
04847
04848 if (initialized)
04849 {
04850 DECL_INLINE (decl) = 1;
04851 if (specbits & (1 << (int) RID_EXTERN))
04852 current_extern_inline = 1;
04853 }
04854 }
04855
04856
04857
04858 else if (flag_inline_trees == 2 && initialized)
04859 {
04860 if (!DECL_INLINE (decl))
04861 DID_INLINE_FUNC (decl) = 1;
04862 DECL_INLINE (decl) = 1;
04863 DECL_DECLARED_INLINE_P (decl) = 0;
04864 }
04865 }
04866 else
04867 {
04868
04869
04870 int extern_ref = !initialized && (specbits & (1 << (int) RID_EXTERN));
04871
04872
04873 if (TREE_CODE (type) == ARRAY_TYPE && type_quals)
04874 {
04875 int saved_align = TYPE_ALIGN(type);
04876 type = build_array_type (c_build_qualified_type (TREE_TYPE (type),
04877 type_quals),
04878 TYPE_DOMAIN (type));
04879 TYPE_ALIGN (type) = saved_align;
04880 #if 0
04881 type_quals = TYPE_UNQUALIFIED;
04882 #endif
04883 }
04884 else if (type_quals)
04885 type = c_build_qualified_type (type, type_quals);
04886
04887 decl = build_decl (VAR_DECL, declarator, type);
04888 if (size_varies)
04889 C_DECL_VARIABLE_SIZE (decl) = 1;
04890
04891 if (inlinep)
04892 pedwarn_with_decl (decl, "variable `%s' declared `inline'");
04893
04894 DECL_EXTERNAL (decl) = extern_ref;
04895
04896
04897
04898
04899
04900 if (current_binding_level == global_binding_level)
04901 {
04902 TREE_PUBLIC (decl) = !(specbits & ((1 << (int) RID_STATIC)
04903 | (1 << (int) RID_REGISTER)));
04904 TREE_STATIC (decl) = !extern_ref;
04905 }
04906
04907 else
04908 {
04909 TREE_STATIC (decl) = (specbits & (1 << (int) RID_STATIC)) != 0;
04910 TREE_PUBLIC (decl) = extern_ref;
04911 }
04912
04913 if (specbits & 1 << (int) RID_THREAD)
04914 {
04915 if (targetm.have_tls)
04916 DECL_THREAD_LOCAL (decl) = 1;
04917 else
04918
04919
04920 error ("thread-local storage not supported for this target");
04921 }
04922 }
04923
04924
04925
04926
04927 if (specbits & (1 << (int) RID_REGISTER))
04928 DECL_REGISTER (decl) = 1;
04929
04930 #if defined(TARG_SL)
04931
04932 tree tmp_type_node;
04933 if (specbits & (1 << (int) RID_SDRAM))
04934 DECL_SDRAM (decl) = 1;
04935 if (specbits & (1 << (int) RID_SBUF))
04936 DECL_SBUF (decl) = 1;
04937
04938 if (specbits & (1 << (int) RID_V1BUF))
04939 {
04940 DECL_V1BUF (decl) = 1;
04941 }
04942 if (specbits & (1 << (int) RID_V2BUF))
04943 {
04944 DECL_V2BUF (decl) = 1;
04945 }
04946 if (specbits & (1 << (int) RID_V4BUF))
04947 {
04948 DECL_V4BUF (decl) = 1;
04949 }
04950
04951 #endif // TARG_SL
04952
04953
04954 c_apply_type_quals_to_decl (type_quals, decl);
04955
04956
04957
04958
04959 if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl)))
04960 c_mark_addressable (decl);
04961
04962 decl_attributes (&decl, returned_attrs, 0);
04963
04964 return decl;
04965 }
04966 }
04967
04968
04969
04970
04971
04972
04973
04974
04975
04976
04977
04978
04979
04980
04981
04982
04983
04984
04985
04986 static tree
04987 grokparms (parms_info, funcdef_flag)
04988 tree parms_info;
04989 int funcdef_flag;
04990 {
04991 tree first_parm = TREE_CHAIN (parms_info);
04992
04993 last_function_parms = TREE_PURPOSE (parms_info);
04994 last_function_parm_tags = TREE_VALUE (parms_info);
04995
04996 if (warn_strict_prototypes && first_parm == 0 && !funcdef_flag
04997 && !in_system_header)
04998 warning ("function declaration isn't a prototype");
04999
05000 if (first_parm != 0
05001 && TREE_CODE (TREE_VALUE (first_parm)) == IDENTIFIER_NODE)
05002 {
05003 if (! funcdef_flag)
05004 pedwarn ("parameter names (without types) in function declaration");
05005
05006 last_function_parms = first_parm;
05007 return 0;
05008 }
05009 else
05010 {
05011 tree parm;
05012 tree typelt;
05013
05014
05015
05016
05017
05018
05019 #if 0
05020
05021 if (funcdef_flag)
05022 #endif
05023 for (parm = last_function_parms, typelt = first_parm;
05024 parm;
05025 parm = TREE_CHAIN (parm))
05026
05027 if (TREE_CODE (parm) == PARM_DECL)
05028 {
05029
05030 tree type = TREE_VALUE (typelt);
05031 if (type == error_mark_node)
05032 continue;
05033 if (!COMPLETE_TYPE_P (type))
05034 {
05035 if (funcdef_flag && DECL_NAME (parm) != 0)
05036 error ("parameter `%s' has incomplete type",
05037 IDENTIFIER_POINTER (DECL_NAME (parm)));
05038 else
05039 warning ("parameter has incomplete type");
05040 if (funcdef_flag)
05041 {
05042 TREE_VALUE (typelt) = error_mark_node;
05043 TREE_TYPE (parm) = error_mark_node;
05044 }
05045 }
05046 #if 0
05047
05048
05049
05050 else
05051 {
05052
05053 while (TREE_CODE (type) == POINTER_TYPE
05054 || TREE_CODE (type) == REFERENCE_TYPE)
05055 type = TREE_TYPE (type);
05056 type = TYPE_MAIN_VARIANT (type);
05057 if (!COMPLETE_TYPE_P (type))
05058 {
05059 if (DECL_NAME (parm) != 0)
05060 warning ("parameter `%s' points to incomplete type",
05061 IDENTIFIER_POINTER (DECL_NAME (parm)));
05062 else
05063 warning ("parameter points to incomplete type");
05064 }
05065 }
05066 #endif
05067 typelt = TREE_CHAIN (typelt);
05068 }
05069
05070 return first_parm;
05071 }
05072 }
05073
05074
05075
05076
05077
05078
05079
05080
05081
05082
05083 tree
05084 get_parm_info (void_at_end)
05085 int void_at_end;
05086 {
05087 tree decl, t;
05088 tree types = 0;
05089 int erred = 0;
05090 tree tags = gettags ();
05091 tree parms = getdecls ();
05092 tree new_parms = 0;
05093 tree order = current_binding_level->parm_order;
05094
05095
05096
05097
05098
05099
05100 if (void_at_end && parms != 0
05101 && TREE_CHAIN (parms) == 0
05102 && VOID_TYPE_P (TREE_TYPE (parms))
05103 && ! TREE_THIS_VOLATILE (parms)
05104 && ! TREE_READONLY (parms)
05105 && ! DECL_REGISTER (parms)
05106 && DECL_NAME (parms) == 0)
05107 {
05108 parms = NULL_TREE;
05109 storedecls (NULL_TREE);
05110 return tree_cons (NULL_TREE, NULL_TREE,
05111 tree_cons (NULL_TREE, void_type_node, NULL_TREE));
05112 }
05113
05114
05115
05116 for (decl = parms; decl;)
05117 {
05118 tree next = TREE_CHAIN (decl);
05119
05120 if (TREE_CODE (decl) != PARM_DECL)
05121 {
05122 TREE_CHAIN (decl) = new_parms;
05123 new_parms = decl;
05124 }
05125 else if (TREE_ASM_WRITTEN (decl))
05126 {
05127 error_with_decl (decl,
05128 "parameter `%s' has just a forward declaration");
05129 TREE_CHAIN (decl) = new_parms;
05130 new_parms = decl;
05131 }
05132 decl = next;
05133 }
05134
05135
05136 for (t = order; t; t = TREE_CHAIN (t))
05137 {
05138 if (TREE_CHAIN (t))
05139 TREE_CHAIN (TREE_VALUE (t)) = TREE_VALUE (TREE_CHAIN (t));
05140 else
05141 TREE_CHAIN (TREE_VALUE (t)) = 0;
05142 }
05143
05144 new_parms = chainon (order ? nreverse (TREE_VALUE (order)) : 0,
05145 new_parms);
05146
05147
05148
05149 storedecls (new_parms);
05150
05151 for (decl = new_parms; decl; decl = TREE_CHAIN (decl))
05152
05153
05154 if (TREE_CODE (decl) == PARM_DECL)
05155 {
05156
05157
05158 tree type = TREE_TYPE (decl);
05159 DECL_ARG_TYPE (decl) = type;
05160 if (PROMOTE_PROTOTYPES
05161 && INTEGRAL_TYPE_P (type)
05162 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
05163 DECL_ARG_TYPE (decl) = integer_type_node;
05164
05165 types = tree_cons (NULL_TREE, TREE_TYPE (decl), types);
05166 if (VOID_TYPE_P (TREE_VALUE (types)) && ! erred
05167 && DECL_NAME (decl) == 0)
05168 {
05169 error ("`void' in parameter list must be the entire list");
05170 erred = 1;
05171 }
05172 }
05173
05174 if (void_at_end)
05175 return tree_cons (new_parms, tags,
05176 nreverse (tree_cons (NULL_TREE, void_type_node, types)));
05177
05178 return tree_cons (new_parms, tags, nreverse (types));
05179 }
05180
05181
05182
05183
05184 void
05185 parmlist_tags_warning ()
05186 {
05187 tree elt;
05188 static int already;
05189
05190 for (elt = current_binding_level->tags; elt; elt = TREE_CHAIN (elt))
05191 {
05192 enum tree_code code = TREE_CODE (TREE_VALUE (elt));
05193
05194
05195 if (code == UNION_TYPE && TREE_PURPOSE (elt) == 0 && !pedantic)
05196 continue;
05197 if (TREE_PURPOSE (elt) != 0)
05198 {
05199 if (code == RECORD_TYPE)
05200 warning ("`struct %s' declared inside parameter list",
05201 IDENTIFIER_POINTER (TREE_PURPOSE (elt)));
05202 else if (code == UNION_TYPE)
05203 warning ("`union %s' declared inside parameter list",
05204 IDENTIFIER_POINTER (TREE_PURPOSE (elt)));
05205 else
05206 warning ("`enum %s' declared inside parameter list",
05207 IDENTIFIER_POINTER (TREE_PURPOSE (elt)));
05208 }
05209 else
05210 {
05211
05212 if (code == RECORD_TYPE)
05213 warning ("anonymous struct declared inside parameter list");
05214 else if (code == UNION_TYPE)
05215 warning ("anonymous union declared inside parameter list");
05216 else
05217 warning ("anonymous enum declared inside parameter list");
05218 }
05219 if (! already)
05220 {
05221 warning ("its scope is only this definition or declaration, which is probably not what you want");
05222 already = 1;
05223 }
05224 }
05225 }
05226
05227
05228
05229
05230 tree
05231 xref_tag (code, name)
05232 enum tree_code code;
05233 tree name;
05234 {
05235
05236
05237
05238 tree ref = lookup_tag (code, name, current_binding_level, 0);
05239
05240
05241
05242
05243
05244
05245
05246
05247
05248
05249
05250 if (ref && TREE_CODE (ref) == code)
05251 return ref;
05252
05253
05254
05255
05256
05257
05258 ref = make_node (code);
05259 if (code == ENUMERAL_TYPE)
05260 {
05261
05262
05263 TYPE_MODE (ref) = TYPE_MODE (unsigned_type_node);
05264 TYPE_ALIGN (ref) = TYPE_ALIGN (unsigned_type_node);
05265 TYPE_USER_ALIGN (ref) = 0;
05266 TREE_UNSIGNED (ref) = 1;
05267 TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node);
05268 TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node);
05269 TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
05270 }
05271
05272 pushtag (name, ref);
05273
05274 return ref;
05275 }
05276
05277
05278
05279
05280
05281 tree
05282 start_struct (code, name)
05283 enum tree_code code;
05284 tree name;
05285 {
05286
05287
05288
05289 tree ref = 0;
05290
05291 if (name != 0)
05292 ref = lookup_tag (code, name, current_binding_level, 1);
05293 if (ref && TREE_CODE (ref) == code)
05294 {
05295 if (TYPE_FIELDS (ref))
05296 {
05297 if (code == UNION_TYPE)
05298 error ("redefinition of `union %s'", IDENTIFIER_POINTER (name));
05299 else
05300 error ("redefinition of `struct %s'", IDENTIFIER_POINTER (name));
05301 }
05302 }
05303 else
05304 {
05305
05306
05307 ref = make_node (code);
05308 pushtag (name, ref);
05309 }
05310
05311 C_TYPE_BEING_DEFINED (ref) = 1;
05312 TYPE_PACKED (ref) = flag_pack_struct;
05313 return ref;
05314 }
05315
05316
05317
05318
05319
05320
05321
05322
05323
05324 tree
05325 grokfield (filename, line, declarator, declspecs, width)
05326 const char *filename ATTRIBUTE_UNUSED;
05327 int line ATTRIBUTE_UNUSED;
05328 tree declarator, declspecs, width;
05329 {
05330 tree value;
05331
05332 if (declarator == NULL_TREE && width == NULL_TREE)
05333 {
05334
05335
05336
05337
05338
05339
05340
05341
05342
05343
05344
05345
05346
05347
05348
05349
05350
05351
05352
05353 tree type = TREE_VALUE (declspecs);
05354
05355 if (flag_ms_extensions && TREE_CODE (type) == TYPE_DECL)
05356 type = TREE_TYPE (type);
05357 if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE)
05358 {
05359 if (flag_ms_extensions)
05360 ;
05361 else if (flag_iso)
05362 goto warn_unnamed_field;
05363 else if (TYPE_NAME (type) == NULL)
05364 ;
05365 else
05366 goto warn_unnamed_field;
05367 }
05368 else
05369 {
05370 warn_unnamed_field:
05371 warning ("declaration does not declare anything");
05372 return NULL_TREE;
05373 }
05374 }
05375
05376 value = grokdeclarator (declarator, declspecs, width ? BITFIELD : FIELD, 0);
05377
05378 finish_decl (value, NULL_TREE, NULL_TREE);
05379 DECL_INITIAL (value) = width;
05380
05381 if (flag_objc)
05382 objc_check_decl (value);
05383 return value;
05384 }
05385
05386
05387
05388
05389 static int
05390 field_decl_cmp (xp, yp)
05391 const PTR xp;
05392 const PTR yp;
05393 {
05394 tree *x = (tree *)xp, *y = (tree *)yp;
05395
05396 if (DECL_NAME (*x) == DECL_NAME (*y))
05397 return 0;
05398 if (DECL_NAME (*x) == NULL)
05399 return -1;
05400 if (DECL_NAME (*y) == NULL)
05401 return 1;
05402 if (DECL_NAME (*x) < DECL_NAME (*y))
05403 return -1;
05404 return 1;
05405 }
05406
05407
05408
05409
05410
05411
05412 tree
05413 finish_struct (t, fieldlist, attributes)
05414 tree t;
05415 tree fieldlist;
05416 tree attributes;
05417 {
05418 tree x;
05419 int toplevel = global_binding_level == current_binding_level;
05420 int saw_named_field;
05421
05422
05423
05424
05425 TYPE_SIZE (t) = 0;
05426
05427 decl_attributes (&t, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
05428
05429
05430 if (! (TREE_CODE (t) == UNION_TYPE && TYPE_NAME (t) == 0) && !pedantic)
05431
05432 if (in_parm_level_p ())
05433 {
05434 if (pedantic)
05435 pedwarn ("%s defined inside parms",
05436 TREE_CODE (t) == UNION_TYPE ? _("union") : _("structure"));
05437 else
05438 warning ("%s defined inside parms",
05439 TREE_CODE (t) == UNION_TYPE ? _("union") : _("structure"));
05440 }
05441
05442 if (pedantic)
05443 {
05444 for (x = fieldlist; x; x = TREE_CHAIN (x))
05445 if (DECL_NAME (x) != 0)
05446 break;
05447
05448 if (x == 0)
05449 pedwarn ("%s has no %s",
05450 TREE_CODE (t) == UNION_TYPE ? _("union") : _("struct"),
05451 fieldlist ? _("named members") : _("members"));
05452 }
05453
05454
05455
05456
05457
05458
05459 saw_named_field = 0;
05460 for (x = fieldlist; x; x = TREE_CHAIN (x))
05461 {
05462 DECL_CONTEXT (x) = t;
05463 DECL_PACKED (x) |= TYPE_PACKED (t);
05464
05465
05466 if (TREE_READONLY (x))
05467 C_TYPE_FIELDS_READONLY (t) = 1;
05468 else
05469 {
05470
05471 tree t1 = TREE_TYPE (x);
05472 while (TREE_CODE (t1) == ARRAY_TYPE)
05473 t1 = TREE_TYPE (t1);
05474 if ((TREE_CODE (t1) == RECORD_TYPE || TREE_CODE (t1) == UNION_TYPE)
05475 && C_TYPE_FIELDS_READONLY (t1))
05476 C_TYPE_FIELDS_READONLY (t) = 1;
05477 }
05478
05479
05480
05481 if (TREE_THIS_VOLATILE (x))
05482 C_TYPE_FIELDS_VOLATILE (t) = 1;
05483
05484
05485 if (C_DECL_VARIABLE_SIZE (x))
05486 C_TYPE_VARIABLE_SIZE (t) = 1;
05487
05488
05489 if (TREE_TYPE (x) == t)
05490 error ("nested redefinition of `%s'",
05491 IDENTIFIER_POINTER (TYPE_NAME (t)));
05492
05493
05494 if (DECL_INITIAL (x))
05495 STRIP_NOPS (DECL_INITIAL (x));
05496 if (DECL_INITIAL (x))
05497 {
05498 if (TREE_CODE (DECL_INITIAL (x)) == INTEGER_CST)
05499 constant_expression_warning (DECL_INITIAL (x));
05500 else
05501 {
05502 error_with_decl (x,
05503 "bit-field `%s' width not an integer constant");
05504 DECL_INITIAL (x) = NULL;
05505 }
05506 }
05507
05508
05509 if (DECL_INITIAL (x)
05510 && TREE_CODE (TREE_TYPE (x)) != INTEGER_TYPE
05511 && TREE_CODE (TREE_TYPE (x)) != BOOLEAN_TYPE
05512 && TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE)
05513 {
05514 error_with_decl (x, "bit-field `%s' has invalid type");
05515 DECL_INITIAL (x) = NULL;
05516 }
05517
05518 if (DECL_INITIAL (x) && pedantic
05519 && TYPE_MAIN_VARIANT (TREE_TYPE (x)) != integer_type_node
05520 && TYPE_MAIN_VARIANT (TREE_TYPE (x)) != unsigned_type_node
05521 && TYPE_MAIN_VARIANT (TREE_TYPE (x)) != c_bool_type_node
05522
05523 && !(TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE
05524 && (TYPE_PRECISION (TREE_TYPE (x))
05525 == TYPE_PRECISION (integer_type_node))))
05526 pedwarn_with_decl (x, "bit-field `%s' type invalid in ISO C");
05527
05528
05529
05530 if (DECL_INITIAL (x))
05531 {
05532 int max_width
05533 = (TYPE_MAIN_VARIANT (TREE_TYPE (x)) == c_bool_type_node
05534 ? CHAR_TYPE_SIZE : TYPE_PRECISION (TREE_TYPE (x)));
05535
05536 if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0)
05537 error_with_decl (x, "negative width in bit-field `%s'");
05538 else if (0 < compare_tree_int (DECL_INITIAL (x), max_width))
05539 pedwarn_with_decl (x, "width of `%s' exceeds its type");
05540 else if (integer_zerop (DECL_INITIAL (x)) && DECL_NAME (x) != 0)
05541 error_with_decl (x, "zero width for bit-field `%s'");
05542 else
05543 {
05544
05545 unsigned HOST_WIDE_INT width
05546 = tree_low_cst (DECL_INITIAL (x), 1);
05547
05548 if (TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE
05549 && (width < min_precision (TYPE_MIN_VALUE (TREE_TYPE (x)),
05550 TREE_UNSIGNED (TREE_TYPE (x)))
05551 || (width
05552 < min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)),
05553 TREE_UNSIGNED (TREE_TYPE (x))))))
05554 warning_with_decl (x,
05555 "`%s' is narrower than values of its type");
05556
05557 DECL_SIZE (x) = bitsize_int (width);
05558 DECL_BIT_FIELD (x) = 1;
05559 SET_DECL_C_BIT_FIELD (x);
05560
05561 if (width == 0
05562 && ! (* targetm.ms_bitfield_layout_p) (t))
05563 {
05564
05565 #ifdef EMPTY_FIELD_BOUNDARY
05566 DECL_ALIGN (x) = MAX (DECL_ALIGN (x), EMPTY_FIELD_BOUNDARY);
05567 #endif
05568 #ifdef PCC_BITFIELD_TYPE_MATTERS
05569 if (PCC_BITFIELD_TYPE_MATTERS)
05570 {
05571 DECL_ALIGN (x) = MAX (DECL_ALIGN (x),
05572 TYPE_ALIGN (TREE_TYPE (x)));
05573 DECL_USER_ALIGN (x) |= TYPE_USER_ALIGN (TREE_TYPE (x));
05574 }
05575 #endif
05576 }
05577 }
05578 }
05579
05580 DECL_INITIAL (x) = 0;
05581
05582
05583 if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
05584 && TYPE_SIZE (TREE_TYPE (x)) == NULL_TREE
05585 && TYPE_DOMAIN (TREE_TYPE (x)) != NULL_TREE
05586 && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE)
05587 {
05588 if (TREE_CODE (t) == UNION_TYPE)
05589 error_with_decl (x, "flexible array member in union");
05590 else if (TREE_CHAIN (x) != NULL_TREE)
05591 error_with_decl (x, "flexible array member not at end of struct");
05592 else if (! saw_named_field)
05593 error_with_decl (x, "flexible array member in otherwise empty struct");
05594 }
05595
05596 if (pedantic && TREE_CODE (t) == RECORD_TYPE
05597 && flexible_array_type_p (TREE_TYPE (x)))
05598 pedwarn_with_decl (x, "invalid use of structure with flexible array member");
05599
05600 if (DECL_NAME (x))
05601 saw_named_field = 1;
05602 }
05603
05604
05605 for (x = fieldlist; x && TREE_CHAIN (x);)
05606
05607 if (DECL_NAME (TREE_CHAIN (x)) == 0)
05608 x = TREE_CHAIN (x);
05609 else
05610 {
05611 tree y = fieldlist;
05612
05613 while (1)
05614 {
05615 if (DECL_NAME (y) == DECL_NAME (TREE_CHAIN (x)))
05616 break;
05617 if (y == x)
05618 break;
05619 y = TREE_CHAIN (y);
05620 }
05621 if (DECL_NAME (y) == DECL_NAME (TREE_CHAIN (x)))
05622 {
05623 error_with_decl (TREE_CHAIN (x), "duplicate member `%s'");
05624 TREE_CHAIN (x) = TREE_CHAIN (TREE_CHAIN (x));
05625 }
05626 else
05627 x = TREE_CHAIN (x);
05628 }
05629
05630
05631
05632
05633 TYPE_FIELDS (t) = fieldlist;
05634
05635 layout_type (t);
05636
05637
05638 {
05639 tree *fieldlistp = &fieldlist;
05640 while (*fieldlistp)
05641 if (TREE_CODE (*fieldlistp) == FIELD_DECL && DECL_INITIAL (*fieldlistp))
05642 *fieldlistp = TREE_CHAIN (*fieldlistp);
05643 else
05644 fieldlistp = &TREE_CHAIN (*fieldlistp);
05645 }
05646
05647
05648
05649
05650 TYPE_FIELDS (t) = fieldlist;
05651
05652
05653
05654
05655 {
05656 int len = 0;
05657
05658 for (x = fieldlist; x; x = TREE_CHAIN (x))
05659 {
05660 if (len > 15 || DECL_NAME (x) == NULL)
05661 break;
05662 len += 1;
05663 }
05664
05665 if (len > 15)
05666 {
05667 tree *field_array;
05668 char *space;
05669
05670 len += list_length (x);
05671
05672
05673
05674
05675
05676 space = ggc_alloc (sizeof (struct lang_type) + len * sizeof (tree));
05677
05678 len = 0;
05679 field_array = &(((struct lang_type *) space)->elts[0]);
05680 for (x = fieldlist; x; x = TREE_CHAIN (x))
05681 {
05682 field_array[len++] = x;
05683
05684
05685 if (DECL_NAME (x) == NULL)
05686 break;
05687 }
05688
05689 if (x == NULL)
05690 {
05691 TYPE_LANG_SPECIFIC (t) = (struct lang_type *) space;
05692 TYPE_LANG_SPECIFIC (t)->len = len;
05693 field_array = &TYPE_LANG_SPECIFIC (t)->elts[0];
05694 qsort (field_array, len, sizeof (tree), field_decl_cmp);
05695 }
05696 }
05697 }
05698
05699 for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
05700 {
05701 TYPE_FIELDS (x) = TYPE_FIELDS (t);
05702 TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
05703 TYPE_ALIGN (x) = TYPE_ALIGN (t);
05704 TYPE_USER_ALIGN (x) = TYPE_USER_ALIGN (t);
05705 }
05706
05707
05708
05709 if (TREE_CODE (t) == UNION_TYPE
05710 && TYPE_TRANSPARENT_UNION (t)
05711 && TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t)))
05712 {
05713 TYPE_TRANSPARENT_UNION (t) = 0;
05714 warning ("union cannot be made transparent");
05715 }
05716
05717
05718
05719
05720 if (current_binding_level->incomplete_list != NULL_TREE)
05721 {
05722 tree prev = NULL_TREE;
05723
05724 for (x = current_binding_level->incomplete_list; x; x = TREE_CHAIN (x))
05725 {
05726 tree decl = TREE_VALUE (x);
05727
05728 if (TYPE_MAIN_VARIANT (TREE_TYPE (decl)) == TYPE_MAIN_VARIANT (t)
05729 && TREE_CODE (decl) != TYPE_DECL)
05730 {
05731 layout_decl (decl, 0);
05732
05733
05734 if (flag_objc)
05735 objc_check_decl (decl);
05736 rest_of_decl_compilation (decl, NULL, toplevel, 0);
05737 if (! toplevel)
05738 expand_decl (decl);
05739
05740 if (prev)
05741 TREE_CHAIN (prev) = TREE_CHAIN (x);
05742 else
05743 current_binding_level->incomplete_list = TREE_CHAIN (x);
05744 }
05745 else if (!COMPLETE_TYPE_P (TREE_TYPE (decl))
05746 && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
05747 {
05748 tree element = TREE_TYPE (decl);
05749 while (TREE_CODE (element) == ARRAY_TYPE)
05750 element = TREE_TYPE (element);
05751 if (element == t)
05752 {
05753 layout_array_type (TREE_TYPE (decl));
05754 if (TREE_CODE (decl) != TYPE_DECL)
05755 {
05756 layout_decl (decl, 0);
05757 if (flag_objc)
05758 objc_check_decl (decl);
05759 rest_of_decl_compilation (decl, NULL, toplevel, 0);
05760 if (! toplevel)
05761 expand_decl (decl);
05762 }
05763
05764 if (prev)
05765 TREE_CHAIN (prev) = TREE_CHAIN (x);
05766 else
05767 current_binding_level->incomplete_list = TREE_CHAIN (x);
05768 }
05769 else
05770 prev = x;
05771 }
05772 else
05773 prev = x;
05774 }
05775 }
05776
05777
05778 rest_of_type_compilation (t, toplevel);
05779
05780 return t;
05781 }
05782
05783
05784
05785 static void
05786 layout_array_type (t)
05787 tree t;
05788 {
05789 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
05790 layout_array_type (TREE_TYPE (t));
05791 layout_type (t);
05792 }
05793
05794
05795
05796
05797
05798
05799
05800 tree
05801 start_enum (name)
05802 tree name;
05803 {
05804 tree enumtype = 0;
05805
05806
05807
05808
05809
05810 if (name != 0)
05811 enumtype = lookup_tag (ENUMERAL_TYPE, name, current_binding_level, 1);
05812
05813 if (enumtype == 0 || TREE_CODE (enumtype) != ENUMERAL_TYPE)
05814 {
05815 enumtype = make_node (ENUMERAL_TYPE);
05816 pushtag (name, enumtype);
05817 }
05818
05819 C_TYPE_BEING_DEFINED (enumtype) = 1;
05820
05821 if (TYPE_VALUES (enumtype) != 0)
05822 {
05823
05824 error ("redeclaration of `enum %s'", IDENTIFIER_POINTER (name));
05825
05826
05827
05828 TYPE_VALUES (enumtype) = 0;
05829 }
05830
05831 enum_next_value = integer_zero_node;
05832 enum_overflow = 0;
05833
05834 if (flag_short_enums)
05835 TYPE_PACKED (enumtype) = 1;
05836
05837 return enumtype;
05838 }
05839
05840
05841
05842
05843
05844
05845
05846 tree
05847 finish_enum (enumtype, values, attributes)
05848 tree enumtype;
05849 tree values;
05850 tree attributes;
05851 {
05852 tree pair, tem;
05853 tree minnode = 0, maxnode = 0, enum_value_type;
05854 int precision, unsign;
05855 int toplevel = (global_binding_level == current_binding_level);
05856
05857 if (in_parm_level_p ())
05858 warning ("enum defined inside parms");
05859
05860 decl_attributes (&enumtype, attributes, (int) ATTR_FLAG_TYPE_IN_PLACE);
05861
05862
05863
05864 if (values == error_mark_node)
05865 minnode = maxnode = integer_zero_node;
05866 else
05867 {
05868 minnode = maxnode = TREE_VALUE (values);
05869 for (pair = TREE_CHAIN (values); pair; pair = TREE_CHAIN (pair))
05870 {
05871 tree value = TREE_VALUE (pair);
05872 if (tree_int_cst_lt (maxnode, value))
05873 maxnode = value;
05874 if (tree_int_cst_lt (value, minnode))
05875 minnode = value;
05876 }
05877 }
05878
05879
05880
05881
05882
05883 unsign = (tree_int_cst_sgn (minnode) >= 0);
05884 precision = MAX (min_precision (minnode, unsign),
05885 min_precision (maxnode, unsign));
05886 if (TYPE_PACKED (enumtype) || precision > TYPE_PRECISION (integer_type_node))
05887 {
05888 tree narrowest = c_common_type_for_size (precision, unsign);
05889 if (narrowest == 0)
05890 {
05891 #ifdef TARG_SL
05892 if (Long_Long_Support == TRUE)
05893 {
05894 warning ("enumeration values exceed range of largest integer");
05895 narrowest = long_long_integer_type_node;
05896 }
05897 else
05898 {
05899 error("\"long long\" is mapped to \"long\", "
05900 "Please use \"-mlong-long\" option to enbale long long type suporting."
05901 "enumeration values exceed range of largest integer");
05902 }
05903 #else
05904 warning ("enumeration values exceed range of largest integer");
05905 narrowest = long_long_integer_type_node;
05906 #endif
05907 }
05908
05909 precision = TYPE_PRECISION (narrowest);
05910 }
05911 else
05912 precision = TYPE_PRECISION (integer_type_node);
05913
05914 if (precision == TYPE_PRECISION (integer_type_node))
05915 enum_value_type = c_common_type_for_size (precision, 0);
05916 else
05917 enum_value_type = enumtype;
05918
05919 TYPE_MIN_VALUE (enumtype) = minnode;
05920 TYPE_MAX_VALUE (enumtype) = maxnode;
05921 TYPE_PRECISION (enumtype) = precision;
05922 TREE_UNSIGNED (enumtype) = unsign;
05923 TYPE_SIZE (enumtype) = 0;
05924 layout_type (enumtype);
05925
05926 if (values != error_mark_node)
05927 {
05928
05929
05930
05931
05932
05933
05934
05935 for (pair = values; pair; pair = TREE_CHAIN (pair))
05936 {
05937 tree enu = TREE_PURPOSE (pair);
05938
05939 TREE_TYPE (enu) = enumtype;
05940 DECL_SIZE (enu) = TYPE_SIZE (enumtype);
05941 DECL_SIZE_UNIT (enu) = TYPE_SIZE_UNIT (enumtype);
05942 DECL_ALIGN (enu) = TYPE_ALIGN (enumtype);
05943 DECL_USER_ALIGN (enu) = TYPE_USER_ALIGN (enumtype);
05944 DECL_MODE (enu) = TYPE_MODE (enumtype);
05945
05946
05947
05948
05949
05950
05951
05952
05953 #ifndef SGI_MONGOOSE
05954 if (int_fits_type_p (DECL_INITIAL (enu), enum_value_type))
05955 DECL_INITIAL (enu) = convert (enum_value_type, DECL_INITIAL (enu));
05956 else
05957 DECL_INITIAL (enu) = convert (enumtype, DECL_INITIAL (enu));
05958 #endif
05959
05960 TREE_PURPOSE (pair) = DECL_NAME (enu);
05961 TREE_VALUE (pair) = DECL_INITIAL (enu);
05962 }
05963
05964 TYPE_VALUES (enumtype) = values;
05965 }
05966
05967
05968 for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem))
05969 {
05970 if (tem == enumtype)
05971 continue;
05972 TYPE_VALUES (tem) = TYPE_VALUES (enumtype);
05973 TYPE_MIN_VALUE (tem) = TYPE_MIN_VALUE (enumtype);
05974 TYPE_MAX_VALUE (tem) = TYPE_MAX_VALUE (enumtype);
05975 TYPE_SIZE (tem) = TYPE_SIZE (enumtype);
05976 TYPE_SIZE_UNIT (tem) = TYPE_SIZE_UNIT (enumtype);
05977 TYPE_MODE (tem) = TYPE_MODE (enumtype);
05978 TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype);
05979 TYPE_ALIGN (tem) = TYPE_ALIGN (enumtype);
05980 TYPE_USER_ALIGN (tem) = TYPE_USER_ALIGN (enumtype);
05981 TREE_UNSIGNED (tem) = TREE_UNSIGNED (enumtype);
05982 }
05983
05984
05985 rest_of_type_compilation (enumtype, toplevel);
05986
05987 return enumtype;
05988 }
05989
05990
05991
05992
05993
05994
05995 tree
05996 build_enumerator (name, value)
05997 tree name, value;
05998 {
05999 tree decl, type;
06000
06001
06002
06003
06004 if (value)
06005 STRIP_TYPE_NOPS (value);
06006
06007 if (value != 0)
06008 {
06009 if (TREE_CODE (value) == INTEGER_CST)
06010 {
06011 value = default_conversion (value);
06012 constant_expression_warning (value);
06013 }
06014 else
06015 {
06016 error ("enumerator value for `%s' not integer constant",
06017 IDENTIFIER_POINTER (name));
06018 value = 0;
06019 }
06020 }
06021
06022
06023
06024
06025 if (value == 0)
06026 {
06027 value = enum_next_value;
06028 if (enum_overflow)
06029 error ("overflow in enumeration values");
06030 }
06031
06032 if (pedantic && ! int_fits_type_p (value, integer_type_node))
06033 {
06034 pedwarn ("ISO C restricts enumerator values to range of `int'");
06035 value = convert (integer_type_node, value);
06036 }
06037
06038
06039 enum_next_value = build_binary_op (PLUS_EXPR, value, integer_one_node, 0);
06040 enum_overflow = tree_int_cst_lt (enum_next_value, value);
06041
06042
06043
06044 type = TREE_TYPE (value);
06045 type = c_common_type_for_size (MAX (TYPE_PRECISION (type),
06046 TYPE_PRECISION (integer_type_node)),
06047 (TYPE_PRECISION (type)
06048 >= TYPE_PRECISION (integer_type_node)
06049 && TREE_UNSIGNED (type)));
06050
06051 decl = build_decl (CONST_DECL, name, type);
06052 DECL_INITIAL (decl) = convert (type, value);
06053 pushdecl (decl);
06054
06055 return tree_cons (decl, value, NULL_TREE);
06056 }
06057
06058
06059
06060
06061
06062
06063
06064
06065
06066
06067
06068
06069
06070
06071 int
06072 start_function (declspecs, declarator, attributes)
06073 tree declarator, declspecs, attributes;
06074 {
06075 tree decl1, old_decl;
06076 tree restype;
06077 int old_immediate_size_expand = immediate_size_expand;
06078
06079 current_function_returns_value = 0;
06080 current_function_returns_null = 0;
06081 current_function_returns_abnormally = 0;
06082 warn_about_return_type = 0;
06083 current_extern_inline = 0;
06084 named_labels = 0;
06085 shadowed_labels = 0;
06086
06087
06088 immediate_size_expand = 0;
06089
06090 decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1);
06091
06092
06093
06094 if (decl1 == 0)
06095 {
06096 immediate_size_expand = old_immediate_size_expand;
06097 return 0;
06098 }
06099
06100 decl_attributes (&decl1, attributes, 0);
06101
06102
06103 if (current_binding_level == global_binding_level)
06104 maybe_apply_pragma_weak (decl1);
06105
06106 if (DECL_DECLARED_INLINE_P (decl1)
06107 && DECL_UNINLINABLE (decl1)
06108 && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
06109 warning_with_decl (decl1,
06110 "inline function `%s' given attribute noinline");
06111
06112 announce_function (decl1);
06113
06114 if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1))))
06115 {
06116 error ("return type is an incomplete type");
06117
06118 TREE_TYPE (decl1)
06119 = build_function_type (void_type_node,
06120 TYPE_ARG_TYPES (TREE_TYPE (decl1)));
06121 }
06122
06123 if (warn_about_return_type)
06124 pedwarn_c99 ("return type defaults to `int'");
06125
06126
06127
06128 current_function_parms = last_function_parms;
06129 current_function_parm_tags = last_function_parm_tags;
06130
06131
06132
06133 DECL_INITIAL (decl1) = error_mark_node;
06134
06135
06136
06137
06138 old_decl = lookup_name_current_level (DECL_NAME (decl1));
06139 if (old_decl != 0 && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE
06140 && !DECL_BUILT_IN (old_decl)
06141 && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
06142 == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (old_decl))))
06143 && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0)
06144 {
06145 TREE_TYPE (decl1) = TREE_TYPE (old_decl);
06146 current_function_prototype_file = DECL_SOURCE_FILE (old_decl);
06147 current_function_prototype_line = DECL_SOURCE_LINE (old_decl);
06148 }
06149
06150
06151
06152 if (old_decl == 0)
06153 old_decl = IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1));
06154
06155
06156 if (warn_strict_prototypes
06157 && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0
06158 && !(old_decl != 0
06159 && (TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0
06160 || (DECL_BUILT_IN (old_decl)
06161 && ! C_DECL_ANTICIPATED (old_decl)))))
06162 warning ("function declaration isn't a prototype");
06163
06164 else if (warn_missing_prototypes
06165 && TREE_PUBLIC (decl1)
06166 && !(old_decl != 0
06167 && (TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0
06168 || (DECL_BUILT_IN (old_decl)
06169 && ! C_DECL_ANTICIPATED (old_decl))))
06170 && ! MAIN_NAME_P (DECL_NAME (decl1)))
06171 warning_with_decl (decl1, "no previous prototype for `%s'");
06172
06173
06174 else if (warn_missing_prototypes
06175 && old_decl != 0 && TREE_USED (old_decl)
06176 && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0)
06177 warning_with_decl (decl1,
06178 "`%s' was used with no prototype before its definition");
06179
06180 else if (warn_missing_declarations
06181 && TREE_PUBLIC (decl1)
06182 && old_decl == 0
06183 && ! MAIN_NAME_P (DECL_NAME (decl1)))
06184 warning_with_decl (decl1, "no previous declaration for `%s'");
06185
06186
06187 else if (warn_missing_declarations
06188 && old_decl != 0 && TREE_USED (old_decl)
06189 && old_decl == IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1)))
06190 warning_with_decl (decl1,
06191 "`%s' was used with no declaration before its definition");
06192
06193
06194
06195
06196
06197 DECL_EXTERNAL (decl1) = current_extern_inline;
06198
06199
06200
06201 TREE_STATIC (decl1) = 1;
06202
06203
06204 if (current_function_decl != 0)
06205 TREE_PUBLIC (decl1) = 0;
06206
06207
06208 if (warn_main > 0 && MAIN_NAME_P (DECL_NAME (decl1)))
06209 {
06210 tree args;
06211 int argct = 0;
06212
06213 if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
06214 != integer_type_node)
06215 pedwarn_with_decl (decl1, "return type of `%s' is not `int'");
06216
06217 for (args = TYPE_ARG_TYPES (TREE_TYPE (decl1)); args;
06218 args = TREE_CHAIN (args))
06219 {
06220 tree type = args ? TREE_VALUE (args) : 0;
06221
06222 if (type == void_type_node)
06223 break;
06224
06225 ++argct;
06226 switch (argct)
06227 {
06228 case 1:
06229 if (TYPE_MAIN_VARIANT (type) != integer_type_node)
06230 pedwarn_with_decl (decl1,
06231 "first argument of `%s' should be `int'");
06232 break;
06233
06234 case 2:
06235 if (TREE_CODE (type) != POINTER_TYPE
06236 || TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
06237 || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type)))
06238 != char_type_node))
06239 pedwarn_with_decl (decl1,
06240 "second argument of `%s' should be `char **'");
06241 break;
06242
06243 case 3:
06244 if (TREE_CODE (type) != POINTER_TYPE
06245 || TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
06246 || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type)))
06247 != char_type_node))
06248 pedwarn_with_decl (decl1,
06249 "third argument of `%s' should probably be `char **'");
06250 break;
06251 }
06252 }
06253
06254
06255
06256
06257 if (argct > 0 && (argct < 2 || argct > 3))
06258 pedwarn_with_decl (decl1, "`%s' takes only zero or two arguments");
06259
06260 if (! TREE_PUBLIC (decl1))
06261 pedwarn_with_decl (decl1, "`%s' is normally a non-static function");
06262 }
06263
06264
06265
06266
06267
06268 current_function_decl = pushdecl (decl1);
06269
06270 pushlevel (0);
06271 declare_parm_level (1);
06272 current_binding_level->subblocks_tag_transparent = 1;
06273
06274 make_decl_rtl (current_function_decl, NULL);
06275
06276 restype = TREE_TYPE (TREE_TYPE (current_function_decl));
06277
06278 if (c_promoting_integer_type_p (restype))
06279 {
06280
06281 if (TREE_UNSIGNED (restype)
06282 && (TYPE_PRECISION (restype)
06283 == TYPE_PRECISION (integer_type_node)))
06284 restype = unsigned_type_node;
06285 else
06286 restype = integer_type_node;
06287 }
06288 DECL_RESULT (current_function_decl)
06289 = build_decl (RESULT_DECL, NULL_TREE, restype);
06290
06291
06292
06293 if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (current_function_decl)))
06294 TREE_ADDRESSABLE (current_function_decl) = 1;
06295
06296 immediate_size_expand = old_immediate_size_expand;
06297
06298 start_fname_decls ();
06299
06300 return 1;
06301 }
06302
06303
06304
06305
06306
06307
06308
06309
06310 void
06311 store_parm_decls ()
06312 {
06313 tree fndecl = current_function_decl;
06314 tree parm;
06315
06316
06317
06318 tree specparms = current_function_parms;
06319
06320
06321 tree parmtags = current_function_parm_tags;
06322
06323
06324 tree parmdecls = getdecls ();
06325
06326
06327
06328
06329 tree nonparms = 0;
06330
06331
06332 tree context = decl_function_context (fndecl);
06333
06334
06335 int prototype = 0;
06336
06337 int saved_warn_shadow = warn_shadow;
06338
06339
06340 warn_shadow = 0;
06341
06342 #ifdef TARG_SL
06343
06344 if (parmdecls)
06345 {
06346 tree parm;
06347 INT float_flag = 0;
06348 for (parm = parmdecls; parm != NULL; parm = TREE_CHAIN(parm))
06349 {
06350 tree type_node = TYPE_MAIN_VARIANT(TREE_TYPE(parm));
06351 if (type_node == float_type_node || type_node == double_type_node)
06352 {
06353 float_flag = 1;
06354 break;
06355 }
06356 }
06357 if (float_flag == 1)
06358 {
06359 error("Old-style function definition is not supported for float/double type");
06360 }
06361 else
06362 {
06363 warning("Old-style function definition");
06364 }
06365 }
06366 #endif
06367
06368 if (specparms != 0 && TREE_CODE (specparms) != TREE_LIST)
06369 {
06370
06371
06372
06373
06374
06375 tree next;
06376 tree others = 0;
06377
06378 prototype = 1;
06379
06380 if (parmdecls != 0)
06381 {
06382 tree decl, link;
06383
06384 error_with_decl (fndecl,
06385 "parm types given both in parmlist and separately");
06386
06387
06388 for (decl = current_binding_level->names;
06389 decl; decl = TREE_CHAIN (decl))
06390 if (DECL_NAME (decl))
06391 IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) = 0;
06392 for (link = current_binding_level->shadowed;
06393 link; link = TREE_CHAIN (link))
06394 IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
06395 current_binding_level->names = 0;
06396 current_binding_level->shadowed = 0;
06397 }
06398
06399 specparms = nreverse (specparms);
06400 for (parm = specparms; parm; parm = next)
06401 {
06402 next = TREE_CHAIN (parm);
06403 if (TREE_CODE (parm) == PARM_DECL)
06404 {
06405 if (DECL_NAME (parm) == 0)
06406 error_with_decl (parm, "parameter name omitted");
06407 else if (TREE_CODE (TREE_TYPE (parm)) != ERROR_MARK
06408 && VOID_TYPE_P (TREE_TYPE (parm)))
06409 {
06410 error_with_decl (parm, "parameter `%s' declared void");
06411
06412
06413 TREE_TYPE (parm) = error_mark_node;
06414 }
06415 pushdecl (parm);
06416 }
06417 else
06418 {
06419
06420
06421 TREE_CHAIN (parm) = 0;
06422 others = chainon (others, parm);
06423 }
06424 }
06425
06426
06427
06428 DECL_ARGUMENTS (fndecl) = getdecls ();
06429
06430 #if 0
06431
06432
06433
06434 if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl))))
06435 != void_type_node)
06436 {
06437 tree dummy = build_decl (PARM_DECL, NULL_TREE, void_type_node);
06438
06439
06440 TREE_TYPE (dummy) = integer_type_node;
06441 DECL_ARG_TYPE (dummy) = integer_type_node;
06442 DECL_ARGUMENTS (fndecl) = chainon (DECL_ARGUMENTS (fndecl), dummy);
06443 }
06444 #endif
06445
06446
06447 for (parm = others; parm; parm = next)
06448 {
06449 next = TREE_CHAIN (parm);
06450 if (DECL_NAME (parm) == 0)
06451 ;
06452 else if (TYPE_MAIN_VARIANT (TREE_TYPE (parm)) == void_type_node)
06453 ;
06454 else if (TREE_CODE (parm) != PARM_DECL)
06455 pushdecl (parm);
06456 }
06457
06458 storetags (chainon (parmtags, gettags ()));
06459 }
06460 else
06461 {
06462
06463
06464
06465
06466
06467
06468
06469
06470
06471
06472
06473
06474
06475
06476 for (parm = parmdecls; parm; parm = TREE_CHAIN (parm))
06477 DECL_WEAK (parm) = 0;
06478
06479 for (parm = specparms; parm; parm = TREE_CHAIN (parm))
06480 {
06481 tree tail, found = NULL;
06482
06483 if (TREE_VALUE (parm) == 0)
06484 {
06485 error_with_decl (fndecl,
06486 "parameter name missing from parameter list");
06487 TREE_PURPOSE (parm) = 0;
06488 continue;
06489 }
06490
06491
06492
06493 for (tail = parmdecls; tail; tail = TREE_CHAIN (tail))
06494 if (DECL_NAME (tail) == TREE_VALUE (parm)
06495 && TREE_CODE (tail) == PARM_DECL)
06496 {
06497 found = tail;
06498 break;
06499 }
06500
06501
06502
06503 if (found && DECL_WEAK (found))
06504 {
06505 error_with_decl (found, "multiple parameters named `%s'");
06506 found = 0;
06507 }
06508
06509
06510 if (found && VOID_TYPE_P (TREE_TYPE (found)))
06511 {
06512 error_with_decl (found, "parameter `%s' declared void");
06513 TREE_TYPE (found) = integer_type_node;
06514 DECL_ARG_TYPE (found) = integer_type_node;
06515 layout_decl (found, 0);
06516 }
06517
06518
06519 if (!found)
06520 {
06521 found = build_decl (PARM_DECL, TREE_VALUE (parm),
06522 integer_type_node);
06523 DECL_ARG_TYPE (found) = TREE_TYPE (found);
06524 DECL_SOURCE_LINE (found) = DECL_SOURCE_LINE (fndecl);
06525 DECL_SOURCE_FILE (found) = DECL_SOURCE_FILE (fndecl);
06526 if (flag_isoc99)
06527 pedwarn_with_decl (found, "type of `%s' defaults to `int'");
06528 else if (extra_warnings)
06529 warning_with_decl (found, "type of `%s' defaults to `int'");
06530 pushdecl (found);
06531 }
06532
06533 TREE_PURPOSE (parm) = found;
06534
06535
06536 DECL_WEAK (found) = 1;
06537 }
06538
06539
06540
06541
06542
06543
06544
06545 nonparms = 0;
06546 for (parm = parmdecls; parm;)
06547 {
06548 tree next = TREE_CHAIN (parm);
06549 TREE_CHAIN (parm) = 0;
06550
06551 if (TREE_CODE (parm) != PARM_DECL)
06552 nonparms = chainon (nonparms, parm);
06553 else
06554 {
06555
06556 if (!COMPLETE_TYPE_P (TREE_TYPE (parm)))
06557 {
06558 error_with_decl (parm, "parameter `%s' has incomplete type");
06559 TREE_TYPE (parm) = error_mark_node;
06560 }
06561
06562 if (! DECL_WEAK (parm))
06563 {
06564 error_with_decl (parm,
06565 "declaration for parameter `%s' but no such parameter");
06566
06567
06568
06569 specparms
06570 = chainon (specparms,
06571 tree_cons (parm, NULL_TREE, NULL_TREE));
06572 }
06573 }
06574
06575 parm = next;
06576 }
06577
06578
06579
06580
06581 parm = specparms;
06582 DECL_ARGUMENTS (fndecl) = 0;
06583 {
06584 tree last;
06585 for (last = 0; parm; parm = TREE_CHAIN (parm))
06586 if (TREE_PURPOSE (parm))
06587 {
06588 if (last == 0)
06589 DECL_ARGUMENTS (fndecl) = TREE_PURPOSE (parm);
06590 else
06591 TREE_CHAIN (last) = TREE_PURPOSE (parm);
06592 last = TREE_PURPOSE (parm);
06593 TREE_CHAIN (last) = 0;
06594 }
06595 }
06596
06597
06598
06599
06600
06601 if (TYPE_ARG_TYPES (TREE_TYPE (fndecl)))
06602 {
06603 tree type;
06604 for (parm = DECL_ARGUMENTS (fndecl),
06605 type = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
06606 parm || (type && (TYPE_MAIN_VARIANT (TREE_VALUE (type))
06607 != void_type_node));
06608 parm = TREE_CHAIN (parm), type = TREE_CHAIN (type))
06609 {
06610 if (parm == 0 || type == 0
06611 || TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
06612 {
06613 error ("number of arguments doesn't match prototype");
06614 error_with_file_and_line (current_function_prototype_file,
06615 current_function_prototype_line,
06616 "prototype declaration");
06617 break;
06618 }
06619
06620
06621
06622 if (! comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)),
06623 TYPE_MAIN_VARIANT (TREE_VALUE (type))))
06624 {
06625 if (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
06626 == TYPE_MAIN_VARIANT (TREE_VALUE (type)))
06627 {
06628
06629
06630
06631
06632
06633 DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
06634
06635 if (PROMOTE_PROTOTYPES
06636 && INTEGRAL_TYPE_P (TREE_TYPE (parm))
06637 && TYPE_PRECISION (TREE_TYPE (parm))
06638 < TYPE_PRECISION (integer_type_node))
06639 DECL_ARG_TYPE (parm) = integer_type_node;
06640
06641 if (pedantic)
06642 {
06643 pedwarn ("promoted argument `%s' doesn't match prototype",
06644 IDENTIFIER_POINTER (DECL_NAME (parm)));
06645 warning_with_file_and_line
06646 (current_function_prototype_file,
06647 current_function_prototype_line,
06648 "prototype declaration");
06649 }
06650 }
06651 else
06652 {
06653 error ("argument `%s' doesn't match prototype",
06654 IDENTIFIER_POINTER (DECL_NAME (parm)));
06655 error_with_file_and_line (current_function_prototype_file,
06656 current_function_prototype_line,
06657 "prototype declaration");
06658 }
06659 }
06660 }
06661 TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = 0;
06662 }
06663
06664
06665
06666 else
06667 {
06668 tree actual = 0, last = 0, type;
06669
06670 for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
06671 {
06672 type = tree_cons (NULL_TREE, DECL_ARG_TYPE (parm), NULL_TREE);
06673 if (last)
06674 TREE_CHAIN (last) = type;
06675 else
06676 actual = type;
06677 last = type;
06678 }
06679 type = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
06680 if (last)
06681 TREE_CHAIN (last) = type;
06682 else
06683 actual = type;
06684
06685
06686
06687
06688
06689
06690
06691
06692
06693 TREE_TYPE (fndecl) = build_type_copy (TREE_TYPE (fndecl));
06694
06695 TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = actual;
06696 }
06697
06698
06699
06700
06701
06702
06703 storedecls (chainon (nonparms, DECL_ARGUMENTS (fndecl)));
06704 }
06705
06706
06707
06708
06709
06710 keep_next_if_subblocks = 1;
06711
06712
06713
06714 #if 0
06715 keep_next_level_flag = 1;
06716 #endif
06717
06718
06719
06720
06721 gen_aux_info_record (fndecl, 1, 0, prototype);
06722
06723
06724 init_function_start (fndecl, input_filename, lineno);
06725
06726
06727 begin_stmt_tree (&DECL_SAVED_TREE (current_function_decl));
06728
06729
06730
06731
06732 if (context)
06733 {
06734 tree t;
06735
06736 DECL_LANG_SPECIFIC (fndecl)->pending_sizes
06737 = nreverse (get_pending_sizes ());
06738 for (t = DECL_LANG_SPECIFIC (fndecl)->pending_sizes;
06739 t;
06740 t = TREE_CHAIN (t))
06741 SAVE_EXPR_CONTEXT (TREE_VALUE (t)) = context;
06742 }
06743
06744
06745 cfun->x_whole_function_mode_p = 1;
06746
06747
06748
06749
06750
06751 immediate_size_expand = 0;
06752 cfun->x_dont_save_pending_sizes_p = 1;
06753
06754 warn_shadow = saved_warn_shadow;
06755
06756 #ifdef SGI_MONGOOSE
06757 #ifndef KEY
06758 if (c_function_varargs)
06759 mark_varargs();
06760 #endif // !KEY
06761 dump_parse_tree ("store_parm_decls", fndecl);
06762 #if 0
06763
06764
06765
06766
06767 if (WFE_Get_Current_Scope () == 1)
06768 #endif
06769 WFE_Start_Function (fndecl);
06770 #endif
06771 }
06772
06773
06774
06775
06776
06777
06778
06779
06780
06781
06782 void
06783 finish_function (nested, can_defer_p)
06784 int nested;
06785 int can_defer_p;
06786 {
06787 tree fndecl = current_function_decl;
06788
06789 #if 0
06790
06791
06792 TREE_READONLY (fndecl) = 1;
06793 #endif
06794
06795 poplevel (1, 0, 1);
06796 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
06797
06798
06799
06800 DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
06801
06802 if (MAIN_NAME_P (DECL_NAME (fndecl)) && flag_hosted)
06803 {
06804 if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
06805 != integer_type_node)
06806 {
06807
06808
06809 if (! warn_main)
06810 pedwarn_with_decl (fndecl, "return type of `%s' is not `int'");
06811 }
06812 else
06813 {
06814 #ifdef DEFAULT_MAIN_RETURN
06815
06816 DEFAULT_MAIN_RETURN;
06817 #else
06818 if (flag_isoc99)
06819 c_expand_return (integer_zero_node);
06820 #endif
06821 }
06822 }
06823
06824 finish_fname_decls ();
06825
06826
06827 finish_stmt_tree (&DECL_SAVED_TREE (fndecl));
06828
06829
06830 if (warn_return_type
06831 && TREE_CODE (TREE_TYPE (TREE_TYPE (fndecl))) != VOID_TYPE
06832 && !current_function_returns_value && !current_function_returns_null
06833
06834 && !current_function_returns_abnormally
06835
06836 && !MAIN_NAME_P (DECL_NAME (fndecl))
06837
06838 && !C_FUNCTION_IMPLICIT_INT (fndecl)
06839
06840
06841 && DECL_INLINE (fndecl))
06842 warning ("no return statement in function returning non-void");
06843
06844
06845
06846 if (extra_warnings
06847 && current_function_returns_value
06848 && current_function_returns_null)
06849 warning ("this function may return with or without a value");
06850
06851
06852 free_after_parsing (cfun);
06853
06854
06855 free_after_compilation (cfun);
06856 cfun = NULL;
06857
06858 if (! nested)
06859 {
06860
06861 c_expand_body (fndecl, nested, can_defer_p);
06862
06863
06864
06865
06866 current_function_decl = NULL;
06867 }
06868 }
06869
06870
06871
06872 void
06873 c_expand_deferred_function (fndecl)
06874 tree fndecl;
06875 {
06876
06877
06878 if (DECL_INLINE (fndecl) && DECL_RESULT (fndecl))
06879 {
06880 #ifdef SGI_MONGOOSE
06881
06882
06883
06884 #if 0
06885
06886
06887
06888
06889
06890 walk_tree_without_duplicates(&DECL_SAVED_TREE(fndecl),
06891 (walk_tree_fn)WFE_Null_ST_References,
06892 NULL);
06893 #endif
06894 WFE_Start_Function(fndecl);
06895 #endif
06896 c_expand_body (fndecl, 0, 0);
06897 current_function_decl = NULL;
06898 }
06899 }
06900
06901
06902
06903
06904
06905 static tree
06906 set_save_expr_context (tp, walk_subtrees, data)
06907 tree *tp;
06908 int *walk_subtrees;
06909 void *data;
06910 {
06911 if (TREE_CODE (*tp) == SAVE_EXPR && !SAVE_EXPR_CONTEXT (*tp))
06912 SAVE_EXPR_CONTEXT (*tp) = (tree) data;
06913
06914
06915 else if (DECL_P (*tp))
06916 *walk_subtrees = 0;
06917
06918 return NULL_TREE;
06919 }
06920
06921
06922
06923
06924
06925
06926 static void
06927 c_expand_body (fndecl, nested_p, can_defer_p)
06928 tree fndecl;
06929 int nested_p, can_defer_p;
06930 {
06931 int uninlinable = 1;
06932 int saved_lineno;
06933 const char *saved_input_filename;
06934 #ifdef SGI_MONGOOSE
06935 tree pdecl;
06936 #endif
06937
06938
06939
06940 if (flag_syntax_only)
06941 return;
06942
06943 saved_lineno = lineno;
06944 saved_input_filename = input_filename;
06945 lineno = DECL_SOURCE_LINE (fndecl);
06946 input_filename = DECL_SOURCE_FILE (fndecl);
06947
06948 #ifdef SGI_MONGOOSE
06949
06950
06951 WFE_Set_Line_And_File (lineno, input_filename);
06952
06953 #if 0
06954
06955
06956 if (nested_p)
06957 WFE_Start_Function (fndecl);
06958 #endif
06959 #endif
06960
06961 if (flag_inline_trees)
06962 {
06963
06964
06965
06966 timevar_push (TV_INTEGRATION);
06967 uninlinable = ! tree_inlinable_function_p (fndecl);
06968
06969 if (! uninlinable && can_defer_p
06970
06971
06972
06973 && defer_fn (fndecl))
06974 {
06975
06976 (*debug_hooks->deferred_inline_function) (fndecl);
06977 timevar_pop (TV_INTEGRATION);
06978 lineno = saved_lineno;
06979 input_filename = saved_input_filename;
06980 #ifdef SGI_MONGOOSE
06981
06982
06983
06984
06985
06986
06987
06988
06989
06990
06991
06992
06993
06994
06995
06996
06997
06998 walk_tree_without_duplicates(&DECL_SAVED_TREE(fndecl),
06999 (walk_tree_fn)WFE_Null_ST_References,
07000 NULL);
07001 defer_function = 1;
07002 WFE_Finish_Function();
07003 defer_function = 0;
07004 for (pdecl = DECL_ARGUMENTS (fndecl); pdecl;
07005 pdecl = TREE_CHAIN (pdecl))
07006 DECL_ST(pdecl) = NULL;
07007 #endif
07008 return;
07009 }
07010
07011
07012 optimize_inline_calls (fndecl);
07013 timevar_pop (TV_INTEGRATION);
07014 }
07015
07016 timevar_push (TV_EXPAND);
07017
07018 if (nested_p)
07019 {
07020
07021
07022 expand_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes);
07023
07024 push_function_context ();
07025 }
07026
07027
07028 current_function_decl = fndecl;
07029 init_function_start (fndecl, input_filename, DECL_SOURCE_LINE (fndecl));
07030
07031
07032 cfun->x_whole_function_mode_p = 1;
07033
07034
07035
07036
07037
07038 immediate_size_expand = 0;
07039 cfun->x_dont_save_pending_sizes_p = 1;
07040
07041
07042 expand_function_start (fndecl, 0);
07043
07044
07045
07046
07047
07048 if (decl_function_context (fndecl)
07049 && variably_modified_type_p (TREE_TYPE (fndecl)))
07050 walk_tree (&TREE_TYPE (fndecl), set_save_expr_context, fndecl,
07051 NULL);
07052
07053
07054
07055 if (DECL_NAME (fndecl)
07056 && MAIN_NAME_P (DECL_NAME (fndecl))
07057 && DECL_CONTEXT (fndecl) == NULL_TREE)
07058 expand_main_function ();
07059
07060
07061 expand_stmt (DECL_SAVED_TREE (fndecl));
07062 #ifdef SGI_MONGOOSE
07063 WFE_Finish_Function();
07064 #endif
07065
07066
07067 if (uninlinable && !dump_enabled_p (TDI_all))
07068 {
07069
07070 DECL_SAVED_TREE (fndecl) = NULL_TREE;
07071 }
07072
07073
07074
07075
07076
07077 immediate_size_expand = 1;
07078
07079
07080 if (lang_expand_function_end)
07081 (*lang_expand_function_end) ();
07082
07083
07084 expand_function_end (input_filename, lineno, 0);
07085
07086
07087
07088 if (nested_p)
07089 ggc_push_context ();
07090
07091
07092 rest_of_compilation (fndecl);
07093
07094
07095 if (nested_p)
07096 ggc_pop_context ();
07097
07098
07099
07100
07101
07102 if (warn_larger_than && !DECL_EXTERNAL (fndecl) && TREE_TYPE (fndecl))
07103 {
07104 tree ret_type = TREE_TYPE (TREE_TYPE (fndecl));
07105
07106 if (ret_type && TYPE_SIZE_UNIT (ret_type)
07107 && TREE_CODE (TYPE_SIZE_UNIT (ret_type)) == INTEGER_CST
07108 && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type),
07109 larger_than_size))
07110 {
07111 unsigned int size_as_int
07112 = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type));
07113
07114 if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0)
07115 warning_with_decl (fndecl,
07116 "size of return value of `%s' is %u bytes",
07117 size_as_int);
07118 else
07119 warning_with_decl (fndecl,
07120 "size of return value of `%s' is larger than %d bytes",
07121 larger_than_size);
07122 }
07123 }
07124
07125 if (DECL_SAVED_INSNS (fndecl) == 0 && ! nested_p
07126 && ! flag_inline_trees)
07127 {
07128
07129
07130
07131
07132
07133 if (DECL_INITIAL (fndecl) != 0)
07134 DECL_INITIAL (fndecl) = error_mark_node;
07135
07136 DECL_ARGUMENTS (fndecl) = 0;
07137 }
07138
07139 if (DECL_STATIC_CONSTRUCTOR (fndecl))
07140 {
07141 #ifndef SGI_MONGOOSE
07142 if (targetm.have_ctors_dtors)
07143 (* targetm.asm_out.constructor) (XEXP (DECL_RTL (fndecl), 0),
07144 DEFAULT_INIT_PRIORITY);
07145 else
07146 static_ctors = tree_cons (NULL_TREE, fndecl, static_ctors);
07147 #else
07148 WFE_Assemble_Constructor (IDENTIFIER_POINTER
07149 (DECL_ASSEMBLER_NAME (fndecl)));
07150 #endif
07151 }
07152
07153 if (DECL_STATIC_DESTRUCTOR (fndecl))
07154 {
07155 #ifndef SGI_MONGOOSE
07156 if (targetm.have_ctors_dtors)
07157 (* targetm.asm_out.destructor) (XEXP (DECL_RTL (fndecl), 0),
07158 DEFAULT_INIT_PRIORITY);
07159 else
07160 static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors);
07161 #else
07162 WFE_Assemble_Destructor (IDENTIFIER_POINTER
07163 (DECL_ASSEMBLER_NAME (fndecl)));
07164 #endif
07165 }
07166
07167 if (nested_p)
07168
07169 pop_function_context ();
07170 timevar_pop (TV_EXPAND);
07171
07172 lineno = saved_lineno;
07173 input_filename = saved_input_filename;
07174 }
07175
07176
07177
07178 void
07179 check_for_loop_decls ()
07180 {
07181 tree t;
07182
07183 if (!flag_isoc99)
07184 {
07185
07186
07187
07188 error ("`for' loop initial declaration used outside C99 mode");
07189 return;
07190 }
07191
07192
07193
07194
07195
07196
07197
07198
07199
07200
07201
07202
07203
07204
07205 for (t = gettags (); t; t = TREE_CHAIN (t))
07206 {
07207 if (TREE_PURPOSE (t) != 0)
07208 {
07209 enum tree_code code = TREE_CODE (TREE_VALUE (t));
07210
07211 if (code == RECORD_TYPE)
07212 error ("`struct %s' declared in `for' loop initial declaration",
07213 IDENTIFIER_POINTER (TREE_PURPOSE (t)));
07214 else if (code == UNION_TYPE)
07215 error ("`union %s' declared in `for' loop initial declaration",
07216 IDENTIFIER_POINTER (TREE_PURPOSE (t)));
07217 else
07218 error ("`enum %s' declared in `for' loop initial declaration",
07219 IDENTIFIER_POINTER (TREE_PURPOSE (t)));
07220 }
07221 }
07222
07223 for (t = getdecls (); t; t = TREE_CHAIN (t))
07224 {
07225 if (TREE_CODE (t) != VAR_DECL && DECL_NAME (t))
07226 error_with_decl (t, "declaration of non-variable `%s' in `for' loop initial declaration");
07227 else if (TREE_STATIC (t))
07228 error_with_decl (t, "declaration of static variable `%s' in `for' loop initial declaration");
07229 else if (DECL_EXTERNAL (t))
07230 error_with_decl (t, "declaration of `extern' variable `%s' in `for' loop initial declaration");
07231 }
07232 }
07233
07234
07235
07236
07237
07238 struct language_function GTY(())
07239 {
07240 struct c_language_function base;
07241 tree named_labels;
07242 tree shadowed_labels;
07243 int returns_value;
07244 int returns_null;
07245 int returns_abnormally;
07246 int warn_about_return_type;
07247 int extern_inline;
07248 struct binding_level *binding_level;
07249 };
07250
07251
07252
07253
07254 void
07255 c_push_function_context (f)
07256 struct function *f;
07257 {
07258 struct language_function *p;
07259 p = ((struct language_function *)
07260 ggc_alloc (sizeof (struct language_function)));
07261 f->language = p;
07262
07263 p->base.x_stmt_tree = c_stmt_tree;
07264 p->base.x_scope_stmt_stack = c_scope_stmt_stack;
07265 p->named_labels = named_labels;
07266 p->shadowed_labels = shadowed_labels;
07267 p->returns_value = current_function_returns_value;
07268 p->returns_null = current_function_returns_null;
07269 p->returns_abnormally = current_function_returns_abnormally;
07270 p->warn_about_return_type = warn_about_return_type;
07271 p->extern_inline = current_extern_inline;
07272 p->binding_level = current_binding_level;
07273 }
07274
07275
07276
07277 void
07278 c_pop_function_context (f)
07279 struct function *f;
07280 {
07281 struct language_function *p = f->language;
07282 tree link;
07283
07284
07285 for (link = shadowed_labels; link; link = TREE_CHAIN (link))
07286 if (DECL_NAME (TREE_VALUE (link)) != 0)
07287 IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)))
07288 = TREE_VALUE (link);
07289
07290 if (DECL_SAVED_INSNS (current_function_decl) == 0
07291 && DECL_SAVED_TREE (current_function_decl) == NULL_TREE)
07292 {
07293
07294
07295
07296 DECL_INITIAL (current_function_decl) = error_mark_node;
07297 DECL_ARGUMENTS (current_function_decl) = 0;
07298 }
07299
07300 c_stmt_tree = p->base.x_stmt_tree;
07301 c_scope_stmt_stack = p->base.x_scope_stmt_stack;
07302 named_labels = p->named_labels;
07303 shadowed_labels = p->shadowed_labels;
07304 current_function_returns_value = p->returns_value;
07305 current_function_returns_null = p->returns_null;
07306 current_function_returns_abnormally = p->returns_abnormally;
07307 warn_about_return_type = p->warn_about_return_type;
07308 current_extern_inline = p->extern_inline;
07309 current_binding_level = p->binding_level;
07310
07311 f->language = NULL;
07312 }
07313
07314
07315
07316 void
07317 c_dup_lang_specific_decl (decl)
07318 tree decl;
07319 {
07320 struct lang_decl *ld;
07321
07322 if (!DECL_LANG_SPECIFIC (decl))
07323 return;
07324
07325 ld = (struct lang_decl *) ggc_alloc (sizeof (struct lang_decl));
07326 memcpy ((char *) ld, (char *) DECL_LANG_SPECIFIC (decl),
07327 sizeof (struct lang_decl));
07328 DECL_LANG_SPECIFIC (decl) = ld;
07329 }
07330
07331
07332
07333
07334
07335
07336
07337
07338
07339
07340 int
07341 stmts_are_full_exprs_p ()
07342 {
07343 return 0;
07344 }
07345
07346
07347
07348
07349
07350 stmt_tree
07351 current_stmt_tree ()
07352 {
07353 return &c_stmt_tree;
07354 }
07355
07356
07357
07358 tree *
07359 current_scope_stmt_stack ()
07360 {
07361 return &c_scope_stmt_stack;
07362 }
07363
07364
07365
07366
07367 int
07368 anon_aggr_type_p (node)
07369 tree node ATTRIBUTE_UNUSED;
07370 {
07371 return 0;
07372 }
07373
07374
07375
07376 void
07377 extract_interface_info ()
07378 {
07379 }
07380
07381
07382
07383
07384 tree
07385 c_begin_compound_stmt ()
07386 {
07387 tree stmt;
07388
07389
07390 stmt = add_stmt (build_stmt (COMPOUND_STMT, NULL_TREE));
07391
07392 return stmt;
07393 }
07394
07395
07396
07397
07398 void
07399 c_expand_decl_stmt (t)
07400 tree t;
07401 {
07402 tree decl = DECL_STMT_DECL (t);
07403
07404
07405 if (TREE_CODE (decl) == FUNCTION_DECL
07406 && DECL_CONTEXT (decl) == current_function_decl
07407 && DECL_SAVED_TREE (decl))
07408 c_expand_body (decl, 1, 0);
07409 }
07410
07411
07412
07413
07414 tree
07415 identifier_global_value (t)
07416 tree t;
07417 {
07418 return IDENTIFIER_GLOBAL_VALUE (t);
07419 }
07420
07421
07422
07423
07424 void
07425 record_builtin_type (rid_index, name, type)
07426 enum rid rid_index;
07427 const char *name;
07428 tree type;
07429 {
07430 tree id;
07431 if (name == 0)
07432 id = ridpointers[(int) rid_index];
07433 else
07434 id = get_identifier (name);
07435 pushdecl (build_decl (TYPE_DECL, id, type));
07436 }
07437
07438
07439 tree
07440 build_void_list_node ()
07441 {
07442 tree t = build_tree_list (NULL_TREE, void_type_node);
07443 return t;
07444 }
07445
07446
07447
07448
07449
07450
07451
07452
07453
07454
07455 tree
07456 make_pointer_declarator (type_quals_attrs, target)
07457 tree type_quals_attrs, target;
07458 {
07459 tree quals, attrs;
07460 tree itarget = target;
07461 split_specs_attrs (type_quals_attrs, &quals, &attrs);
07462 if (attrs != NULL_TREE)
07463 itarget = tree_cons (attrs, target, NULL_TREE);
07464 return build1 (INDIRECT_REF, quals, itarget);
07465 }
07466
07467 #include "gt-c-decl.h"