aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2003-12-31 00:45:27 +0000
committerMark Mitchell <mark@codesourcery.com>2003-12-31 00:45:27 +0000
commitbd51323a0fde3e8a60299a95eb64f705f6162d13 (patch)
treef1e0c7a519aa1e332c7c10a8a8e599ba99f615f8
parentc9b0b5e83e93dd604c0c5cef4c0bbc5d95d24c3f (diff)
Merge from mainline
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/csl-arm-branch@75254 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--ChangeLog4
-rw-r--r--MAINTAINERS1
-rw-r--r--gcc/ChangeLog391
-rw-r--r--gcc/Makefile.in9
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/gnat_ug.texi2
-rw-r--r--gcc/ada/gnat_ug_unx.texi2
-rw-r--r--gcc/ada/gnat_ug_vms.texi2
-rw-r--r--gcc/ada/gnat_ug_vxw.texi2
-rw-r--r--gcc/ada/gnat_ug_wnt.texi2
-rw-r--r--gcc/basic-block.h46
-rw-r--r--gcc/bt-load.c19
-rw-r--r--gcc/c-common.c6
-rw-r--r--gcc/cfg.c2
-rw-r--r--gcc/cfglayout.c8
-rw-r--r--gcc/cfglayout.h4
-rw-r--r--gcc/cfgloop.c41
-rw-r--r--gcc/cfgloop.h14
-rw-r--r--gcc/cfgloopanal.c31
-rw-r--r--gcc/cfgloopmanip.c133
-rw-r--r--gcc/common.opt16
-rw-r--r--gcc/config/alpha/alpha-modes.def2
-rw-r--r--gcc/config/alpha/alpha.c4
-rw-r--r--gcc/config/alpha/alpha.h2
-rw-r--r--gcc/config/alpha/elf.h4
-rw-r--r--gcc/config/alpha/lib1funcs.asm2
-rw-r--r--gcc/config/alpha/openbsd.h2
-rw-r--r--gcc/config/alpha/unicosmk.h1
-rw-r--r--gcc/config/alpha/vms-cc.c10
-rw-r--r--gcc/config/alpha/vms-crt0-64.c2
-rw-r--r--gcc/config/alpha/vms-crt0.c2
-rw-r--r--gcc/config/alpha/vms-ld.c12
-rw-r--r--gcc/config/alpha/vms-psxcrt0-64.c2
-rw-r--r--gcc/config/alpha/vms-psxcrt0.c2
-rw-r--r--gcc/config/alpha/vms.h2
-rw-r--r--gcc/config/arc/arc.c2
-rw-r--r--gcc/config/arc/arc.h1
-rw-r--r--gcc/config/arm/aof.h4
-rw-r--r--gcc/config/arm/arm-modes.def2
-rw-r--r--gcc/config/arm/arm.c30
-rw-r--r--gcc/config/arm/arm.h46
-rw-r--r--gcc/config/arm/arm.md26
-rw-r--r--gcc/config/arm/linux-elf.h2
-rw-r--r--gcc/config/arm/vxworks.h2
-rw-r--r--gcc/config/avr/avr.c77
-rw-r--r--gcc/config/avr/avr.h33
-rw-r--r--gcc/config/avr/avr.md4
-rw-r--r--gcc/config/darwin.h2
-rw-r--r--gcc/config/elfos.h4
-rw-r--r--gcc/config/h8300/h8300.md8
-rw-r--r--gcc/config/i386/i386-interix.h14
-rw-r--r--gcc/config/i386/i386.c101
-rw-r--r--gcc/config/i386/i386.h4
-rw-r--r--gcc/config/i386/i386.md38
-rw-r--r--gcc/config/i386/i386elf.h8
-rw-r--r--gcc/config/i386/ptx4-i.h8
-rw-r--r--gcc/config/i386/sco5.h1
-rw-r--r--gcc/config/i386/sysv4.h8
-rw-r--r--gcc/config/i386/x86-64.h1
-rw-r--r--gcc/config/ia64/ia64.c12
-rw-r--r--gcc/config/m32r/m32r.h1
-rw-r--r--gcc/config/m32r/m32r.md2
-rw-r--r--gcc/config/m68k/uclinux.h2
-rw-r--r--gcc/config/mcore/mcore-elf.h3
-rw-r--r--gcc/config/mips/mips.c6
-rw-r--r--gcc/config/mips/t-iris66
-rw-r--r--gcc/config/netware.h1
-rw-r--r--gcc/config/ns32k/ns32k.c100
-rw-r--r--gcc/config/ptx4.h1
-rw-r--r--gcc/config/rs6000/rs6000.c4
-rw-r--r--gcc/config/rs6000/rs6000.md10
-rw-r--r--gcc/config/sparc/linux64.h4
-rw-r--r--gcc/config/sparc/liteelf.h1
-rw-r--r--gcc/config/sparc/sol26-sld.h7
-rw-r--r--gcc/config/sparc/sp86x-elf.h1
-rw-r--r--gcc/config/vxworks.h1
-rw-r--r--gcc/config/xtensa/elf.h2
-rw-r--r--gcc/config/xtensa/xtensa-protos.h2
-rw-r--r--gcc/config/xtensa/xtensa.c64
-rw-r--r--gcc/config/xtensa/xtensa.h66
-rw-r--r--gcc/coverage.c48
-rw-r--r--gcc/cp/ChangeLog56
-rw-r--r--gcc/cp/call.c21
-rw-r--r--gcc/cp/class.c12
-rw-r--r--gcc/cp/decl.c29
-rw-r--r--gcc/cp/parser.c12
-rw-r--r--gcc/cp/pt.c3
-rw-r--r--gcc/cp/semantics.c1
-rw-r--r--gcc/cp/tree.c11
-rw-r--r--gcc/cp/typeck.c24
-rw-r--r--gcc/defaults.h2
-rw-r--r--gcc/doc/c-tree.texi4
-rw-r--r--gcc/doc/cpp.texi2
-rw-r--r--gcc/doc/cppopts.texi2
-rw-r--r--gcc/doc/install.texi2
-rw-r--r--gcc/doc/invoke.texi170
-rw-r--r--gcc/doc/md.texi5
-rw-r--r--gcc/doc/tm.texi8
-rw-r--r--gcc/dominance.c346
-rw-r--r--gcc/dwarf2out.c2
-rw-r--r--gcc/dwarfout.c6396
-rw-r--r--gcc/et-forest.c1090
-rw-r--r--gcc/et-forest.h42
-rw-r--r--gcc/f/ChangeLog11
-rw-r--r--gcc/f/com.c28
-rw-r--r--gcc/fold-const.c14
-rw-r--r--gcc/function.c21
-rw-r--r--gcc/function.h4
-rw-r--r--gcc/gcc.c2
-rw-r--r--gcc/gcse.c25
-rw-r--r--gcc/graph.c25
-rw-r--r--gcc/ifcvt.c49
-rw-r--r--gcc/java/ChangeLog8
-rw-r--r--gcc/java/parse.y27
-rw-r--r--gcc/longlong.h2
-rw-r--r--gcc/loop-init.c5
-rw-r--r--gcc/loop-unroll.c80
-rw-r--r--gcc/loop-unswitch.c21
-rw-r--r--gcc/opts.c51
-rw-r--r--gcc/predict.c60
-rw-r--r--gcc/sbitmap.c13
-rw-r--r--gcc/sched-rgn.c13
-rw-r--r--gcc/stor-layout.c4
-rw-r--r--gcc/testsuite/ChangeLog128
-rw-r--r--gcc/testsuite/g++.dg/abi/vbase10.C8
-rw-r--r--gcc/testsuite/g++.old-deja/g++.jason/thunk2.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.jason/thunk3.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.law/profile1.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/explicit71.C2
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20020604-1.c2
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/920625-1.c6
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/961203-1.c2
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/980506-1.c2
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/981006-1.c2
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/981223-1.c8
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/loop-2e.x7
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/loop-2f.x9
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/loop-2g.x9
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/strct-varg-1.x7
-rw-r--r--gcc/testsuite/gcc.dg/20020312-2.c6
-rw-r--r--gcc/testsuite/lib/gcc-dg.exp34
-rw-r--r--gcc/toplev.c11
-rw-r--r--gcc/version.c2
-rw-r--r--libiberty/ChangeLog4
-rw-r--r--libiberty/cp-demangle.c3
-rw-r--r--libjava/ChangeLog210
-rw-r--r--libjava/Makefile.am2
-rw-r--r--libjava/Makefile.in6
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java6
-rw-r--r--libjava/gnu/java/net/protocol/http/Connection.java324
-rw-r--r--libjava/gnu/java/rmi/server/UnicastConnectionManager.java3
-rw-r--r--libjava/gnu/java/rmi/server/UnicastRemoteCall.java99
-rw-r--r--libjava/gnu/java/rmi/server/UnicastServer.java2
-rw-r--r--libjava/gnu/java/rmi/server/UnicastServerRef.java7
-rw-r--r--libjava/java/awt/Choice.java50
-rw-r--r--libjava/java/io/BufferedReader.java34
-rw-r--r--libjava/java/io/CharArrayReader.java2
-rw-r--r--libjava/java/io/FileInputStream.java15
-rw-r--r--libjava/java/io/LineNumberReader.java138
-rw-r--r--libjava/java/io/ObjectInputStream.java1048
-rw-r--r--libjava/java/io/ObjectOutputStream.java679
-rw-r--r--libjava/java/io/ObjectStreamClass.java842
-rw-r--r--libjava/java/net/ServerSocket.java10
-rw-r--r--libjava/java/rmi/Naming.java33
-rw-r--r--libjava/javax/print/attribute/ResolutionSyntax.java2
-rw-r--r--libjava/javax/print/attribute/SetOfIntegerSyntax.java2
-rw-r--r--libjava/javax/print/attribute/Size2DSyntax.java2
-rw-r--r--libjava/javax/print/attribute/standard/Copies.java2
-rw-r--r--libjava/javax/print/attribute/standard/JobImpressions.java2
-rw-r--r--libjava/javax/print/attribute/standard/JobMediaSheets.java2
-rw-r--r--libjava/javax/print/attribute/standard/NumberOfDocuments.java2
-rw-r--r--libjava/javax/print/attribute/standard/NumberOfInterveningJobs.java2
-rw-r--r--libjava/javax/print/attribute/standard/PagesPerMinute.java2
-rw-r--r--libjava/javax/print/attribute/standard/PagesPerMinuteColor.java2
-rw-r--r--libjava/javax/print/attribute/standard/QueuedJobCount.java2
-rw-r--r--libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c55
-rw-r--r--libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c8
-rw-r--r--libjava/jni/gtk-peer/gtkpeer.h3
-rw-r--r--libjava/libltdl/ltdl.c6
-rw-r--r--libstdc++-v3/ChangeLog33
-rw-r--r--libstdc++-v3/acinclude.m47
-rw-r--r--libstdc++-v3/aclocal.m47
-rw-r--r--libstdc++-v3/config/cpu/i386/atomicity.h5
-rwxr-xr-xlibstdc++-v3/configure3
-rw-r--r--libstdc++-v3/include/bits/c++config2
-rw-r--r--libstdc++-v3/include/bits/locale_facets.h7
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc21
-rw-r--r--libstdc++-v3/include/c_std/std_cmath.h1
-rw-r--r--libstdc++-v3/include/ext/pool_allocator.h8
189 files changed, 4728 insertions, 9493 deletions
diff --git a/ChangeLog b/ChangeLog
index ccceb2f219a..5f1d9cfa967 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-12-23 Kazu Hirata <kazu@cs.umass.edu>
+
+ * MAINTAINERS: Remove the mn10200 maintainer.
+
2003-12-21 Bernardo Innocenti <bernie@develer.com>
* configure.in (*-*-uclinux): Exclude newlib, libgloss and rda.
diff --git a/MAINTAINERS b/MAINTAINERS
index ebc9db30fd7..db62e1f8e2f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -61,7 +61,6 @@ m68k-motorola-sysv port Philippe De Muyter phdm@macqel.be
mcore port Nick Clifton nickc@redhat.com
mips port Eric Christopher echristo@redhat.com
mmix port Hans-Peter Nilsson hp@bitrange.com
-mn10200 port Jeff Law law@redhat.com
mn10300 port Jeff Law law@redhat.com
mn10300 port Alexandre Oliva aoliva@redhat.com
ns32k port Ian Dall ian@beware.dropbear.id.au
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8b0cd527275..65db0bb4aa0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2003-30-12 Paul Brook <paul@codesourcery.com>
+ * longlong.h: protect arm inlines with !defined (__thumb__)
+
+2003-30-12 Paul Brook <paul@codesourcery.com>
+
* config/arm/arm.h (TARGET_CPU_CPP_BUILTINS): Always define __arm__.
2003-12-30 Nathan Sidwell <nathan@codesourcery.com>
@@ -215,8 +219,351 @@
* config/arm/arm-generic.md: Likewise.
* config/arm/arm1026ejs.md: Likewise.
+2003-12-30 Mark Mitchell <mark@codesourcery.com>
+
+ * stor-layout.c (layout_decl): Turn bitfields into ordinary
+ fields, even if they are the first field in a structure.
+
+2003-12-30 Roger Sayle <roger@eyesopen.com>
+
+ * fold-const.c (fold) <COND_EXPR>: Don't require strict type
+ equality, instead just prevent replacing a COND_EXPR of non-void
+ type by one of its operands of void type.
+
+2003-12-30 Andreas Schwab <schwab@suse.de>
+
+ * doc/c-tree.texi: Fix @item vs. @itemx.
+ * doc/cpp.texi: Likewise.
+ * doc/install.texi: Likewise.
+ * doc/invoke.texi: Likewise.
+
+2003-12-30 Nathan Sidwell <nathan@codesourcery.com>
+
+ * builtins.c (expand_builtin_apply_args_1): Fix typo in previous
+ change.
+
+2003-12-30 Jan Hubicka <jh@suse.cz>
+
+ PR ice/11936
+ * i386.h (CLASS_LIKELY_SPILLED_P): Return true for
+ FP_TOP_REG/FP_SECOND_REG.
+
+2003-12-30 Steven Bosscher <steven@gcc.gnu.org>
+
+ Backport from tree-ssa (relevant changes only):
+ 2003-12-18 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
+
+ * et-forest.h (et_forest_create, et_forest_delete,
+ et_forest_add_node, et_forest_add_edge, et_forest_remove_node,
+ et_forest_remove_edge, et_forest_parent,
+ et_forest_common_ancestor, et_forest_node_value,
+ et_forest_enumerate_sons): Declarations removed.
+ (struct et_node): New.
+ (et_new_tree, et_free_tree, et_set_father, et_split, et_nca,
+ et_below): Declare.
+ * et-forest.c (struct et_forest_occurrence, struct et_forest,
+ struct et_forest_node): Removed.
+ (et_forest_create, et_forest_delete,
+ et_forest_add_node, et_forest_add_edge, et_forest_remove_node,
+ et_forest_remove_edge, et_forest_parent,
+ et_forest_common_ancestor, et_forest_node_value,
+ et_forest_enumerate_sons, splay, remove_all_occurrences,
+ find_leftmost_node, find_rightmost_node, calculate_value): Removed.
+ (struct et_occ): New.
+ (et_nodes, et_occurences): New.
+ (set_depth, set_depth_add, set_prev, set_next, et_recomp_min,
+ et_check_occ_sanity, et_check_sanity, et_check_tree_sanity,
+ record_path_before_1, record_path_before, check_path_after_1,
+ check_path_after, et_splay, et_new_occ, et_new_tree,
+ et_free_tree, et_set_father, et_split, et_nca, et_below): New.
+ * basic-block.h (struct basic_block_def): New field dom.
+ (struct dominance_info): Type removed.
+ (calculate_dominance_info, free_dominance_info,
+ nearest_common_dominator, set_immediate_dominator,
+ get_immediate_dominator, dominated_by_p, get_dominated_by,
+ add_to_dominance_info, delete_from_dominance_info,
+ recount_dominator, redirect_immediate_dominators,
+ iterate_fix_dominators, verify_dominators): Declarations
+ changed.
+ (enum dom_state): New.
+ (dom_computed): New variable.
+ (first_dom_son, next_dom_son): Declare.
+ * dominance.c (struct dominance_info): Removed.
+ (BB_NODE, SET_BB_NODE): Removed.
+ (calculate_dominance_info, free_dominance_info,
+ nearest_common_dominator, set_immediate_dominator,
+ get_immediate_dominator, dominated_by_p, get_dominated_by,
+ add_to_dominance_info, delete_from_dominance_info,
+ recount_dominator, redirect_immediate_dominators,
+ iterate_fix_dominators, verify_dominators,
+ debug_dominance_info): Work over new datastructure. Access
+ dominance datastructures through CFG.
+ (assign_dfs_numbers, compute_dom_fast_query, first_dom_son,
+ next_dom_son): New.
+ * bt-load.c (dom): Variable removed.
+ (augment_live_range, combine_btr_defs, migrate_btr_def,
+ migrate_btr_defs, branch_target_load_optimize): Updated for the
+ new interface for dominance information.
+ * cfg.c {exit_entry_blocks): Update initializer.
+ * cfglayout.c (copy_bbs): Removed loops argument. Updated for
+ the new interface for dominance information.
+ * cfglayout.h (copy_bbs): Declaration changed.
+ * cfgloop.c (flow_loop_pre_header_find, flow_loops_cfg_dump,
+ flow_loop_scan, canonicalize_loop_headers, flow_loops_find): Updated
+ for the new interface for dominance information.
+ (flow_loop_scan): Loops argument removed.
+ (flow_loops_free): Don't release dominators.
+ * cfgloop.h (struct cfg): Dom field removed.
+ (flow_loop_scan, loop_split_edge_with, simple_loop_p,
+ just_once_each_iteration_p, split_loop_bb): Declaration changed.
+ * cfgloopanal.c (simple_loop_exit_p, simple_increment,
+ just_once_each_iteration_p, simple_loop_p): Remove loops argument.
+ Updated for the new interface for dominance information.
+ * cfgloopmanip.c (remove_bbs, find_path, create_preheader,
+ split_loop_bb, loopify, duplicate_loop_to_header_edge,
+ force_single_succ_latches, loop_split_edge_with): Ditto.
+ * gcse.c (dominators): Variable removed.
+ (free_code_hoist_mem, compute_code_hoist_data, hoist_code):
+ Updated for the new interface for dominance information.
+ * ifcvt.c (post_dominators): Variable removed.
+ (mark_loop_exit_edges, merge_if_block, find_if_header,
+ find_cond_trap, find_if_case_1, find_if_case_2, if_convert):
+ Updated for the new interface for dominance information.
+ * loop-init.c (rtl_loop_optimizer_init,
+ rtl_loop_optimizer_finalize): Ditto.
+ * loop-unroll.c (decide_peel_simple, decide_peel_once_rolling,
+ decide_peel_completely, decide_unroll_stupid,
+ decide_unroll_constant_iterations,
+ decide_unroll_runtime_iterations): Loops argument removed.
+ Updated for the new interface for dominance information.
+ (unroll_and_peel_loops, peel_loops_completely,
+ unroll_loop_runtime_iterations): Updated for the new interface for
+ dominance information.
+ * loop-unswitch.c (may_unswitch_on_p, unswitch_loops,
+ unswitch_single_loop, unswitch_loop): Updated for the new
+ interface for dominance information.
+ * predict.c (process_note_predictions, process_note_prediction,
+ estimate_probability, note_prediction_to_br_prob): Ditto.
+ * sched-rgn.c (find_rgns, init_regions): Ditto.
+ * toplev.c (rest_of_handle_branch_prob): Free the dominators.
+
+2003-12-30 Jan Hubicka <jh@suse.cz>
+
+ PR target/13456
+ * i386.md (allocate_stack_worker): Use different pattern for pre and
+ post reload expansion.
+ (allocate_stack_worker_1, allocate_stack_worker_rex64): Use
+ match_scratch.
+ (allocate_stack_worder_1_postreload,
+ allocate_stack_worker_rex64_postreload): New.
+
+2003-12-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ * builtins.c (expand_builtin_apply_args_1): Add pretend args size
+ to the virtual incoming args pointer for downward stacks.
+
+2003-12-29 Roger Sayle <roger@eyesopen.com>
+
+ PR fortran/12632
+ * fold-const.c (fold) <COND_EXPR>: Don't fold a constant condition,
+ if the type of the selected branch doesn't match its' parent.
+
+2003-12-29 Jan Hubicka <jh@suse.cz>
+
+ * coverage.c (read_counts_file): Better error messages; cause corrupted
+ profiles to produce hard errors, not just warnings
+ (get_coverage_counts): Similarly.
+
+ * toplev.c (rest_of_handle_loop_optimize): Enable LOOP_AUTO_UNROLL.
+
+2003-12-29 Phil Edwards <phil@codesourcery.com>
+
+ * doc/cppopts.texi: Use of -idirafter, -iprefix, -iwithprefix, and
+ -iwithprefixbefore is not discouraged.
+
+2003-12-28 Mostafa Hagog <mustafa@il.ibm.com>
+
+ * sbitmap.c (sbitmap_union_of_diff_cg, sbitmap_a_and_b_cg,
+ sbitmap_a_xor_b_cg): Accumulate "changed" properly.
+ (sbitmap_not): Zero all bits past n_bit.
+
+2003-12-27 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
+
+ PR opt/13159
+ * cfgloopanal.c (mark_irreducible_loops): Fix the strongly connected
+ components detection.
+ * loop-unswitch.c (unswitch_loop): Preserve simple preheaders.
+
+2003-12-27 Bernardo Innocenti <bernie@develer.com>
+
+ * config/m68k/uclinux.h (LIB_SPEC): Add elf2flt magic required for
+ correct linking of executables using id-based shared libraries.
+
+2003-12-27 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/i386/i386-interix.h: Remove uses of "register"
+ specifier in declarations of arguments and local variables.
+ * config/i386/i386.c: Likewise.
+ * config/i386/i386elf.h: Likewise.
+ * config/i386/ptx4-i.h: Likewise.
+ * config/i386/sysv4.h: Likewise.
+
+2003-12-26 Fariborz Jahanian <fjahanian@apple.com>
+ Geoffrey Keating <geoffk@apple.com>
+ David Edelsohn <edelsohn@gnu.org>
+
+ * config/rs6000/rs6000.c (legitimate_offset_address_p): Do not
+ restrict DFmode and TFmode to word alignment.
+ * config/rs6000/rs6000.md (movdf_hardfloat64): Use 'o' constraint
+ for ld/std and order before mr.
+
+2003-12-26 Andrew Pinski <pinskia@physics.uc.edu>
+
+ * config/darwin.h (LINK_COMMAND_SPEC): Arrange
+ -fprofile-generate to imply -lgcov.
+
+2003-12-26 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/h8300/h8300.md (ldm_h8300s_2_normal): Use HImode for
+ addresses.
+
+2003-12-25 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/m32r/m32r.md: Remove a constraint from a splitter.
+
+2003-12-25 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR C++/13429, C/11944
+ * c-common.c (c_build_qualified_type): Return early when type is
+ error_mark_node.
+ (c_apply_type_quals_to_decl): Likewise.
+
+2003-12-25 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/alpha/alpha-modes.def: Fix comment formatting.
+ * config/alpha/alpha.c: Likewise.
+ * config/alpha/alpha.h: Likewise.
+ * config/alpha/elf.h: Likewise.
+ * config/alpha/lib1funcs.asm: Likewise.
+ * config/alpha/openbsd.h: Likewise.
+ * config/alpha/vms-cc.c: Likewise.
+ * config/alpha/vms-crt0-64.c: Likewise.
+ * config/alpha/vms-crt0.c: Likewise.
+ * config/alpha/vms-ld.c: Likewise.
+ * config/alpha/vms-psxcrt0-64.c: Likewise.
+ * config/alpha/vms-psxcrt0.c: Likewise.
+ * config/alpha/vms.h: Likewise.
+ * config/arc/arc.c: Likewise.
+ * config/arm/aof.h: Likewise.
+ * config/arm/arm-modes.def: Likewise.
+ * config/arm/arm.c: Likewise.
+ * config/arm/arm.h: Likewise.
+ * config/arm/arm.md: Likewise.
+ * config/arm/linux-elf.h: Likewise.
+ * config/arm/vxworks.h: Likewise.
+ * config/avr/avr.c: Likewise.
+ * config/avr/avr.h: Likewise.
+
+2003-12-24 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/xtensa/elf.h: Fix comment formatting.
+ * config/xtensa/xtensa-protos.h: Likewise.
+ * config/xtensa/xtensa.c: Likewise.
+ * config/xtensa/xtensa.h: Likewise.
+
+2003-12-24 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/avr/avr.c: Fix comment formatting.
+ * config/avr/avr.md: Likewise.
+
+2003-12-24 Kazu Hirata <kazu@cs.umass.edu>
+
+ PR target/12721.
+ * config/avr/avr.c: Include ggc.h.
+ (tmp_reg_rtx): Declare with GTY.
+ (zero_reg_rtx): Likewise.
+ (ldi_reg_rtx): Remove.
+ (avr_override_options): Initialize zero_reg_rtx and
+ ldi_reg_rtx.
+ (avr_init): Remove.
+ Include gt-avr.h.
+ * config/avr/avr.h (LDI_REG_REGNO): Remove.
+ Remove externs for tmp_reg_rtx, zero_reg_rtx, and ldi_reg_rtx.
+
+2003-12-24 David Edelsohn <edelsohn@gnu.org>
+
+ * doc/md.texi: Document PowerPC vector register constraint letter.
+
2003-12-23 Mark Mitchell <mark@codesourcery.com>
+ * calls.c (expand_call): Recognize calls to "sqrt" and create
+ corresponding notes.
+
+2003-12-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * config/mips/mips.c (override_options): Use `inform' instead
+ of `warning' for -g -mabi=32 and native assembler.
+
+ * config/mips/t-iris6 (CRTSTUFF_T_CFLAGS, TARGET_LIBGCC2_CFLAGS):
+ Don't pass -Wno-error.
+
+2003-12-23 David Edelsohn <edelsohn@gnu.org>
+
+ * function.c (assign_parms): Update max_parm_reg and
+ parm_reg_stack_loc when adding new parm reg.
+
+2003-12-23 Kazu Hirata <kazu@cs.umass.edu>
+
+ * config/ns32k/ns32k.c: Convert to ISO-C.
+
+2003-12-23 Zack Weinberg <zack@codesourcery.com>
+
+ * config/ia64/ia64.c (ia64_va_arg): Pass pointer for
+ variable-sized type through convert_memory_address.
+ (ia64_in_small_data_p): Always return false for FUNCTION_DECLs.
+
+2003-12-23 Jan Hubicka <jh@suse.cz>
+
+ * common.opt (fprofile-generate,fprofile-use): Add.
+ * gcc.c (LINK_COMMAND_SPEC): Arrange -fprofile-generate to imply -lgcov
+ * opts.c (profile_arc_flag_set, flag_profile_values_set,
+ flag_unroll_loops_set, flag_tracer_set,
+ flag_value_profile_transformations_set,
+ flag_peel_loops_set): New static variables.
+ (common_handle_option): Deal with -fprofile-generate/-fprofile-use
+ * invoke.texi (-fprofile-generate, -fprofile-use): Describe.
+
+2003-12-23 Mark Mitchell <mark@codesourcery.com>
+
+ * Makefile.in (OBJS-common): Remove dwarfout.o.
+ (dwarfout.o): Remove.
+ * common.opt: Remove -gdwarf, -gdwarf+.
+ * defaults.h (PREFERRED_DEBUGGING_TYPE): Do not check for
+ DWARF_DEBUGGING_INFO.
+ * dwarf2out.c: Fix typo in comment.
+ * dwarfout.c: Remove.
+ * opts.c (common_handle_option): Remove OPT_gdwarf, OPT_gdwarf_.
+ * toplev.c (process_options): Remove check for
+ DWARF_DEBUGGING_INFO.
+ * config/elfos.h (DWARF_DEBUGGING_INFO): Do not #define it or
+ #undef it.
+ * config/netware.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/ptx4.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/vxworks.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/alpha/unicosmk.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/arc/arc.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/i386/sco5.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/i386/x86-64.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/m32r/m32r.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/mcore/mcore-elf.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/sparc/linux64.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/sparc/liteelf.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/sparc/sol26-sld.h (DWARF_DEBUGGING_INFO): Likewise.
+ * config/sparc/sp86x-elf.h (DWARF_DEBUGGING_INFO): Likewise.
+ * doc/invoke.texi: Do not mention -gdwarf, -gdwarf-1, -gdwarf-1+,
+ or -gdwarf+.
+ * doc/tm.texi: Likewise.
+
* c-common.c (flag_abi_version): Default to 2.
* c-cppbuiltin.c (c_cpp_builtins): Define __GXX_ABI_VERSION
uniformly for versions above 2.
@@ -253,7 +600,7 @@
-falt-external-templates and -ftemplates.
* doc/invoke.texi: Remove mention of -fexternal-templates and
-falt-external-templates.
-
+
2003-12-22 Andrew Pinski <pinskia@physics.uc.edu>
PR target/13466
@@ -268,24 +615,24 @@
2003-12-22 Fariborz Jahanian <fjahanian@apple.com>
- * config/rs6000/rs6000.c (legitimate_offset_address_p): Correct
- check for the legitimate offset when memory of
- DImode/DFmode/TFmode/TImode mode is being referenced and target
+ * config/rs6000/rs6000.c (legitimate_offset_address_p): Correct
+ check for the legitimate offset when memory of
+ DImode/DFmode/TFmode/TImode mode is being referenced and target
is TARGET_POWERPC64.
2003-12-22 Dale Johannesen <dalej@apple.com>
- * reload1.c: Add reg_reloaded_call_part_clobbered.
- (reload_as_needed): Use it.
- (forget_old_reloads_1): Ditto.
- (emit_reload_insns): Ditto.
+ * reload1.c: Add reg_reloaded_call_part_clobbered.
+ (reload_as_needed): Use it.
+ (forget_old_reloads_1): Ditto.
+ (emit_reload_insns): Ditto.
2003-12-22 Dale Johannesen <dalej@apple.com>
- PR optimization/12828
- * loop.c: Add find_regs_nested to look inside CLOBBER(MEM).
- (scan_loop): Call it.
- * regclass.c (reg_scan_mark_regs): Look inside CLOBBER(MEM).
+ PR optimization/12828
+ * loop.c: Add find_regs_nested to look inside CLOBBER(MEM).
+ (scan_loop): Call it.
+ * regclass.c (reg_scan_mark_regs): Look inside CLOBBER(MEM).
2003-12-22 Andrew Pinski <pinskia@physics.uc.edu>
@@ -313,7 +660,7 @@
* configure.in (gather-detailed-mem-stats): New flag.
* configure: Regenerate.
* config.in: Regenerate.
- * doc/install.texi (Configuration): Document
+ * doc/install.texi (Configuration): Document
--enable-gather-detailed-mem-stats.
2003-12-22 Kazu Hirata <kazu@cs.umass.edu>
@@ -386,7 +733,7 @@
* config/mn10300/mn10300.c: Likewise.
2003-12-20 Andrew Pinski <pinskia@gcc.gnu.org>
- Matt Thomas <matt@3am-software.com>
+ Matt Thomas <matt@3am-software.com>
PR target/12749
* config/i386/i386.c (print_operand): Print only the first
@@ -486,11 +833,11 @@
* gcc/config/i386/i386.c (ix86_expand_call, x86_output_mi_thunk):
Trivial fixes for i386.c on Darwin/x86.
-
+
2003-12-19 Fariborz Jahanian <fjahanian@apple.com>
- * config/rs6000/rs6000.c (legitimate_lo_sum_address_p): Add code to
- recognize macho-style lo_sum adrress patterns.
+ * config/rs6000/rs6000.c (legitimate_lo_sum_address_p): Add code to
+ recognize macho-style lo_sum adrress patterns.
2003-12-19 Kazu Hirata <kazu@cs.umass.edu>
@@ -600,7 +947,7 @@
2003-12-18 Ulrich Weigand <uweigand@de.ibm.com>
- * loop.c (move_movables): Handle combination of m->consec,
+ * loop.c (move_movables): Handle combination of m->consec,
m->move_insn_first, and m->insert_temp all nonzero correctly.
2003-12-18 Kazu Hirata <kazu@cs.umass.edu>
@@ -629,7 +976,7 @@
2003-12-17 James E Wilson <wilson@specifixinc.com>
Roger Sayle <roger@eyesopen.com>
-
+
* Makefile.in (gcse.o): Add $(TREE_H) to dependencies.
* gcse.c: Include tree.h.
(implicit_set_cond_p): New.
@@ -718,7 +1065,7 @@
* config/m32r/m32r.md (cmp_ne_small_const_insn): Remove.
2003-12-17 Neil Booth <neil@daikokuya.co.uk>
- Joseph S. Myers <jsm@polyomino.org.uk>
+ Joseph S. Myers <jsm@polyomino.org.uk>
PR c/3347
* c-decl.c (enum_decl_context): Remove BITFIELD.
@@ -748,7 +1095,7 @@
* ginclude/stddef.h (offsetof): Reimplement for C++, using
__offsetof__.
* doc/extend.texi: Document __offsetof__.
-
+
2003-12-16 Stan Cox <scox@redhat.com>
* config/iq2000/iq2000.h: Formatting.
@@ -787,7 +1134,7 @@
* altivec.h (vec_cmple, vec_all_numeric): Fix typo.
* testsuite/gcc.dg/altivec-10.c: Test for above.
-
+
2003-12-15 David O'Brien <obrien@FreeBSD.org>
* Makefile.in (CPPFLAGS): Initialize from configure.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 75d6e76f388..bd65e0bf67e 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -852,7 +852,7 @@ OBJS-common = \
cfgloopanal.o cfgloopmanip.o loop-init.o loop-unswitch.o loop-unroll.o \
cfgrtl.o combine.o conflict.o convert.o coverage.o cse.o cselib.o \
dbxout.o debug.o df.o diagnostic.o dojump.o doloop.o dominance.o \
- dwarf2asm.o dwarf2out.o dwarfout.o emit-rtl.o except.o explow.o \
+ dwarf2asm.o dwarf2out.o emit-rtl.o except.o explow.o \
expmed.o expr.o final.o flow.o fold-const.o function.o gcse.o \
genrtl.o ggc-common.o global.o graph.o gtype-desc.o \
haifa-sched.o hooks.o ifcvt.o insn-attrtab.o insn-emit.o insn-modes.o \
@@ -1322,7 +1322,7 @@ c-convert.o : c-convert.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H)
c-pragma.o: c-pragma.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
function.h c-pragma.h toplev.h output.h $(GGC_H) $(TM_P_H) $(C_COMMON_H) gt-c-pragma.h
graph.o: graph.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) toplev.h flags.h output.h \
- $(RTL_H) function.h hard-reg-set.h $(BASIC_BLOCK_H) graph.h
+ $(RTL_H) function.h langhooks.h hard-reg-set.h $(BASIC_BLOCK_H) graph.h $(TREE_H)
sbitmap.o: sbitmap.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h \
hard-reg-set.h $(BASIC_BLOCK_H)
@@ -1604,9 +1604,6 @@ sdbout.o : sdbout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_
flags.h function.h $(EXPR_H) output.h hard-reg-set.h $(REGS_H) real.h \
insn-config.h xcoffout.h c-pragma.h $(GGC_H) $(TARGET_H) \
sdbout.h toplev.h $(TM_P_H) except.h debug.h langhooks.h gt-sdbout.h
-dwarfout.o : dwarfout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
- $(RTL_H) dwarf.h flags.h insn-config.h reload.h output.h toplev.h $(TM_P_H) \
- debug.h langhooks.h $(TARGET_H)
dwarf2out.o : dwarf2out.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) dwarf2.h debug.h flags.h insn-config.h reload.h output.h $(DIAGNOSTIC_H) real.h \
hard-reg-set.h $(REGS_H) $(EXPR_H) libfuncs.h toplev.h dwarf2out.h varray.h \
@@ -1654,7 +1651,7 @@ web.o : web.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
hard-reg-set.h flags.h $(BASIC_BLOCK_H) function.h output.h toplev.h df.h
gcse.o : gcse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
hard-reg-set.h flags.h real.h insn-config.h $(GGC_H) $(RECOG_H) $(EXPR_H) \
- $(BASIC_BLOCK_H) function.h output.h toplev.h $(TM_P_H) $(PARAMS_H) \
+ $(BASIC_BLOCK_H) function.h langhooks.h output.h toplev.h $(TM_P_H) $(PARAMS_H) \
except.h gt-gcse.h $(TREE_H)
sibcall.o : sibcall.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
function.h hard-reg-set.h flags.h insn-config.h $(RECOG_H) $(BASIC_BLOCK_H)
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index e942341d1a9..a49c825dc86 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,11 @@
+2003-12-23 Kelley Cook <kcook@gcc.gnu.org>
+
+ * gnat_ug.texi: Force a CVS commit by updating copyright.
+ * gnat_ug_vxw.texi: Regenerate.
+ * gnat_ug_wnt.texi: Regenerate.
+ * gnat_ug_vms.texi: Regenerate.
+ * gnat_ug_unx.texi: Regenerate.
+
2003-12-20 Kazu Hirata <kazu@cs.umass.edu>
* trans.c: Remove uses of "register" specifier in
diff --git a/gcc/ada/gnat_ug.texi b/gcc/ada/gnat_ug.texi
index f631ca6e5c9..946da534211 100644
--- a/gcc/ada/gnat_ug.texi
+++ b/gcc/ada/gnat_ug.texi
@@ -79,7 +79,7 @@
@c %**end of header
@copying
-Copyright @copyright{} 1995-2002, Free Software Foundation
+Copyright @copyright{} 1995-2003, Free Software Foundation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
diff --git a/gcc/ada/gnat_ug_unx.texi b/gcc/ada/gnat_ug_unx.texi
index e0924e4750f..484f5a75b19 100644
--- a/gcc/ada/gnat_ug_unx.texi
+++ b/gcc/ada/gnat_ug_unx.texi
@@ -65,7 +65,7 @@
@c %**end of header
@copying
-Copyright @copyright{} 1995-2002, Free Software Foundation
+Copyright @copyright{} 1995-2003, Free Software Foundation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
diff --git a/gcc/ada/gnat_ug_vms.texi b/gcc/ada/gnat_ug_vms.texi
index e717a20fa1e..89bc0e17b49 100644
--- a/gcc/ada/gnat_ug_vms.texi
+++ b/gcc/ada/gnat_ug_vms.texi
@@ -65,7 +65,7 @@
@c %**end of header
@copying
-Copyright @copyright{} 1995-2002, Free Software Foundation
+Copyright @copyright{} 1995-2003, Free Software Foundation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
diff --git a/gcc/ada/gnat_ug_vxw.texi b/gcc/ada/gnat_ug_vxw.texi
index 50d7c9dd9ba..8fb949d1c6e 100644
--- a/gcc/ada/gnat_ug_vxw.texi
+++ b/gcc/ada/gnat_ug_vxw.texi
@@ -65,7 +65,7 @@
@c %**end of header
@copying
-Copyright @copyright{} 1995-2002, Free Software Foundation
+Copyright @copyright{} 1995-2003, Free Software Foundation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
diff --git a/gcc/ada/gnat_ug_wnt.texi b/gcc/ada/gnat_ug_wnt.texi
index 24390ffb555..1d799b2792f 100644
--- a/gcc/ada/gnat_ug_wnt.texi
+++ b/gcc/ada/gnat_ug_wnt.texi
@@ -65,7 +65,7 @@
@c %**end of header
@copying
-Copyright @copyright{} 1995-2002, Free Software Foundation
+Copyright @copyright{} 1995-2003, Free Software Foundation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 9b664a1f748..2e8f5786348 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -234,6 +234,9 @@ typedef struct basic_block_def {
/* Outermost loop containing the block. */
struct loop *loop_father;
+ /* The dominance and postdominance information node. */
+ struct et_node *dom[2];
+
/* Expected number of executions: calculated in profile.c. */
gcov_type count;
@@ -373,10 +376,6 @@ extern void clear_edges (void);
extern void mark_critical_edges (void);
extern rtx first_insn_after_basic_block_note (basic_block);
-/* Dominator information for basic blocks. */
-
-typedef struct dominance_info *dominance_info;
-
/* Structure to group all of the information to process IF-THEN and
IF-THEN-ELSE blocks for the conditional execution support. This
needs to be in a public file in case the IFCVT macros call
@@ -612,22 +611,35 @@ enum cdi_direction
CDI_POST_DOMINATORS
};
-extern dominance_info calculate_dominance_info (enum cdi_direction);
-extern void free_dominance_info (dominance_info);
-extern basic_block nearest_common_dominator (dominance_info,
+enum dom_state
+{
+ DOM_NONE, /* Not computed at all. */
+ DOM_CONS_OK, /* The data is conservatively OK, i.e. if it says you that A dominates B,
+ it indeed does. */
+ DOM_NO_FAST_QUERY, /* The data is OK, but the fast query data are not usable. */
+ DOM_OK /* Everything is ok. */
+};
+
+extern enum dom_state dom_computed[2];
+
+extern void calculate_dominance_info (enum cdi_direction);
+extern void free_dominance_info (enum cdi_direction);
+extern basic_block nearest_common_dominator (enum cdi_direction,
basic_block, basic_block);
-extern void set_immediate_dominator (dominance_info, basic_block,
+extern void set_immediate_dominator (enum cdi_direction, basic_block,
basic_block);
-extern basic_block get_immediate_dominator (dominance_info, basic_block);
-extern bool dominated_by_p (dominance_info, basic_block, basic_block);
-extern int get_dominated_by (dominance_info, basic_block, basic_block **);
-extern void add_to_dominance_info (dominance_info, basic_block);
-extern void delete_from_dominance_info (dominance_info, basic_block);
-basic_block recount_dominator (dominance_info, basic_block);
-extern void redirect_immediate_dominators (dominance_info, basic_block,
+extern basic_block get_immediate_dominator (enum cdi_direction, basic_block);
+extern bool dominated_by_p (enum cdi_direction, basic_block, basic_block);
+extern int get_dominated_by (enum cdi_direction, basic_block, basic_block **);
+extern void add_to_dominance_info (enum cdi_direction, basic_block);
+extern void delete_from_dominance_info (enum cdi_direction, basic_block);
+basic_block recount_dominator (enum cdi_direction, basic_block);
+extern void redirect_immediate_dominators (enum cdi_direction, basic_block,
basic_block);
-void iterate_fix_dominators (dominance_info, basic_block *, int);
-extern void verify_dominators (dominance_info);
+extern void iterate_fix_dominators (enum cdi_direction, basic_block *, int);
+extern void verify_dominators (enum cdi_direction);
+extern basic_block first_dom_son (enum cdi_direction, basic_block);
+extern basic_block next_dom_son (enum cdi_direction, basic_block);
#include "cfghooks.h"
diff --git a/gcc/bt-load.c b/gcc/bt-load.c
index 6f77a203202..2a68cd76bdb 100644
--- a/gcc/bt-load.c
+++ b/gcc/bt-load.c
@@ -155,9 +155,6 @@ static void note_btr_set (rtx, rtx, void *);
migrating branch target load instructions. */
static struct obstack migrate_btrl_obstack;
-/* Basic block dominator information used when migrating PT instructions. */
-static dominance_info dom;
-
/* Array indexed by basic block number, giving the set of registers
live in that block. */
static HARD_REG_SET *btrs_live;
@@ -840,9 +837,9 @@ augment_live_range (bitmap live_range, HARD_REG_SET *btrs_live_in_range,
tos = worklist = xmalloc (sizeof (basic_block) * (n_basic_blocks + 1));
- if (dominated_by_p (dom, new_bb, head_bb))
+ if (dominated_by_p (CDI_DOMINATORS, new_bb, head_bb))
*tos++ = new_bb;
- else if (dominated_by_p (dom, head_bb, new_bb))
+ else if (dominated_by_p (CDI_DOMINATORS, head_bb, new_bb))
{
edge e;
int new_block = new_bb->index;
@@ -974,7 +971,7 @@ combine_btr_defs (btr_def def, HARD_REG_SET *btrs_live_in_range)
if (other_def != def
&& other_def->uses != NULL
&& ! other_def->has_ambiguous_use
- && dominated_by_p (dom, other_def->bb, def->bb))
+ && dominated_by_p (CDI_DOMINATORS, other_def->bb, def->bb))
{
/* def->bb dominates the other def, so def and other_def could
be combined. */
@@ -1226,9 +1223,9 @@ migrate_btr_def (btr_def def, int min_cost)
def_basic_block_freq = basic_block_freq (def->bb);
- for (try = get_immediate_dominator (dom, def->bb);
+ for (try = get_immediate_dominator (CDI_DOMINATORS, def->bb);
!give_up && try && try != ENTRY_BLOCK_PTR && def->cost >= min_cost;
- try = get_immediate_dominator (dom, try))
+ try = get_immediate_dominator (CDI_DOMINATORS, try))
{
/* Try to move the instruction that sets the target register into
basic block TRY. */
@@ -1299,7 +1296,7 @@ migrate_btr_defs (enum reg_class btr_class, int allow_callee_save)
"Basic block %d: count = " HOST_WIDEST_INT_PRINT_DEC
" loop-depth = %d idom = %d\n",
i, (HOST_WIDEST_INT) bb->count, bb->loop_depth,
- get_immediate_dominator (dom, bb)->index);
+ get_immediate_dominator (CDI_DOMINATORS, bb)->index);
}
}
@@ -1367,12 +1364,12 @@ branch_target_load_optimize (rtx insns, bool after_prologue_epilogue_gen)
life_analysis (insns, NULL, 0);
/* Dominator info is also needed for migrate_btr_def. */
- dom = calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_DOMINATORS);
migrate_btr_defs (class,
((*targetm.branch_target_register_callee_saved)
(after_prologue_epilogue_gen)));
- free_dominance_info (dom);
+ free_dominance_info (CDI_DOMINATORS);
update_life_info (NULL, UPDATE_LIFE_GLOBAL_RM_NOTES,
PROP_DEATH_NOTES | PROP_REG_INFO);
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 9cdd1441098..3ba73dd2722 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -2784,6 +2784,9 @@ static tree builtin_function_2 (const char *, const char *, tree, tree,
tree
c_build_qualified_type (tree type, int type_quals)
{
+ if (type == error_mark_node)
+ return type;
+
if (TREE_CODE (type) == ARRAY_TYPE)
return build_array_type (c_build_qualified_type (TREE_TYPE (type),
type_quals),
@@ -2809,6 +2812,9 @@ void
c_apply_type_quals_to_decl (int type_quals, tree decl)
{
tree type = TREE_TYPE (decl);
+
+ if (type == error_mark_node)
+ return;
if (((type_quals & TYPE_QUAL_CONST)
|| (type && TREE_CODE (type) == REFERENCE_TYPE))
diff --git a/gcc/cfg.c b/gcc/cfg.c
index 32da973369c..96dac25d0ac 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -111,6 +111,7 @@ struct basic_block_def entry_exit_blocks[2]
EXIT_BLOCK_PTR, /* next_bb */
0, /* loop_depth */
NULL, /* loop_father */
+ { NULL, NULL }, /* dom */
0, /* count */
0, /* frequency */
0, /* flags */
@@ -133,6 +134,7 @@ struct basic_block_def entry_exit_blocks[2]
NULL, /* next_bb */
0, /* loop_depth */
NULL, /* loop_father */
+ { NULL, NULL }, /* dom */
0, /* count */
0, /* frequency */
0, /* flags */
diff --git a/gcc/cfglayout.c b/gcc/cfglayout.c
index 14138a764de..15ec0547451 100644
--- a/gcc/cfglayout.c
+++ b/gcc/cfglayout.c
@@ -1253,7 +1253,7 @@ end:
void
copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs,
edge *edges, unsigned n_edges, edge *new_edges,
- struct loop *base, struct loops *loops)
+ struct loop *base)
{
unsigned i, j;
basic_block bb, new_bb, dom_bb;
@@ -1268,7 +1268,7 @@ copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs,
bb->rbi->duplicated = 1;
/* Add to loop. */
add_bb_to_loop (new_bb, bb->loop_father->copy);
- add_to_dominance_info (loops->cfg.dom, new_bb);
+ add_to_dominance_info (CDI_DOMINATORS, new_bb);
/* Possibly set header. */
if (bb->loop_father->header == bb && bb->loop_father != base)
new_bb->loop_father->header = new_bb;
@@ -1283,11 +1283,11 @@ copy_bbs (basic_block *bbs, unsigned n, basic_block *new_bbs,
bb = bbs[i];
new_bb = new_bbs[i];
- dom_bb = get_immediate_dominator (loops->cfg.dom, bb);
+ dom_bb = get_immediate_dominator (CDI_DOMINATORS, bb);
if (dom_bb->rbi->duplicated)
{
dom_bb = dom_bb->rbi->copy;
- set_immediate_dominator (loops->cfg.dom, new_bb, dom_bb);
+ set_immediate_dominator (CDI_DOMINATORS, new_bb, dom_bb);
}
}
diff --git a/gcc/cfglayout.h b/gcc/cfglayout.h
index 3258fe8fba5..ca79e26c433 100644
--- a/gcc/cfglayout.h
+++ b/gcc/cfglayout.h
@@ -43,5 +43,5 @@ extern void insn_locators_initialize (void);
extern void reemit_insn_block_notes (void);
extern bool can_copy_bbs_p (basic_block *, unsigned);
extern void copy_bbs (basic_block *, unsigned, basic_block *,
- edge *, unsigned, edge *, struct loop *, struct loops *);
-extern void cfg_layout_initialize_rbi (basic_block);
+ edge *, unsigned, edge *, struct loop *);
+extern void cfg_layout_initialize_rbi (basic_block);
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 413b606608b..43c52f23ddb 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -38,7 +38,7 @@ static void flow_loop_entry_edges_find (struct loop *);
static void flow_loop_exit_edges_find (struct loop *);
static int flow_loop_nodes_find (basic_block, struct loop *);
static void flow_loop_pre_header_scan (struct loop *);
-static basic_block flow_loop_pre_header_find (basic_block, dominance_info);
+static basic_block flow_loop_pre_header_find (basic_block);
static int flow_loop_level_compute (struct loop *);
static int flow_loops_level_compute (struct loops *);
static void establish_preds (struct loop *);
@@ -55,7 +55,7 @@ flow_loops_cfg_dump (const struct loops *loops, FILE *file)
int i;
basic_block bb;
- if (! loops->num || ! file || ! loops->cfg.dom)
+ if (! loops->num || ! file)
return;
FOR_EACH_BB (bb)
@@ -212,9 +212,6 @@ flow_loops_free (struct loops *loops)
free (loops->parray);
loops->parray = NULL;
- if (loops->cfg.dom)
- free_dominance_info (loops->cfg.dom);
-
if (loops->cfg.dfs_order)
free (loops->cfg.dfs_order);
if (loops->cfg.rc_order)
@@ -391,11 +388,10 @@ flow_loop_pre_header_scan (struct loop *loop)
}
/* Return the block for the pre-header of the loop with header
- HEADER where DOM specifies the dominator information. Return NULL if
- there is no pre-header. */
+ HEADER. Return NULL if there is no pre-header. */
static basic_block
-flow_loop_pre_header_find (basic_block header, dominance_info dom)
+flow_loop_pre_header_find (basic_block header)
{
basic_block pre_header;
edge e;
@@ -408,7 +404,7 @@ flow_loop_pre_header_find (basic_block header, dominance_info dom)
basic_block node = e->src;
if (node != ENTRY_BLOCK_PTR
- && ! dominated_by_p (dom, node, header))
+ && ! dominated_by_p (CDI_DOMINATORS, node, header))
{
if (pre_header == NULL)
pre_header = node;
@@ -522,7 +518,7 @@ flow_loops_level_compute (struct loops *loops)
about it specified by FLAGS. */
int
-flow_loop_scan (struct loops *loops, struct loop *loop, int flags)
+flow_loop_scan (struct loop *loop, int flags)
{
if (flags & LOOP_ENTRY_EDGES)
{
@@ -541,8 +537,7 @@ flow_loop_scan (struct loops *loops, struct loop *loop, int flags)
if (flags & LOOP_PRE_HEADER)
{
/* Look to see if the loop has a pre-header node. */
- loop->pre_header
- = flow_loop_pre_header_find (loop->header, loops->cfg.dom);
+ loop->pre_header = flow_loop_pre_header_find (loop->header);
/* Find the blocks within the extended basic block of
the loop pre-header. */
@@ -627,12 +622,11 @@ make_forwarder_block (basic_block bb, int redirect_latch, int redirect_nonlatch,
static void
canonicalize_loop_headers (void)
{
- dominance_info dom;
basic_block header;
edge e;
/* Compute the dominators. */
- dom = calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_DOMINATORS);
alloc_aux_for_blocks (sizeof (int));
alloc_aux_for_edges (sizeof (int));
@@ -651,7 +645,7 @@ canonicalize_loop_headers (void)
have_abnormal_edge = 1;
if (latch != ENTRY_BLOCK_PTR
- && dominated_by_p (dom, latch, header))
+ && dominated_by_p (CDI_DOMINATORS, latch, header))
{
num_latches++;
LATCH_EDGE (e) = 1;
@@ -663,6 +657,8 @@ canonicalize_loop_headers (void)
HEADER_BLOCK (header) = num_latches;
}
+ free_dominance_info (CDI_DOMINATORS);
+
if (HEADER_BLOCK (ENTRY_BLOCK_PTR->succ->dest))
{
basic_block bb;
@@ -728,7 +724,6 @@ canonicalize_loop_headers (void)
free_aux_for_blocks ();
free_aux_for_edges ();
- free_dominance_info (dom);
}
/* Find all the natural loops in the function and save in LOOPS structure and
@@ -744,7 +739,6 @@ flow_loops_find (struct loops *loops, int flags)
int num_loops;
edge e;
sbitmap headers;
- dominance_info dom;
int *dfs_order;
int *rc_order;
basic_block header;
@@ -770,7 +764,7 @@ flow_loops_find (struct loops *loops, int flags)
canonicalize_loop_headers ();
/* Compute the dominators. */
- dom = loops->cfg.dom = calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_DOMINATORS);
/* Count the number of loop headers. This should be the
same as the number of natural loops. */
@@ -804,7 +798,8 @@ flow_loops_find (struct loops *loops, int flags)
node (header) that dominates all the nodes in the
loop. It also has single back edge to the header
from a latch node. */
- if (latch != ENTRY_BLOCK_PTR && dominated_by_p (dom, latch, header))
+ if (latch != ENTRY_BLOCK_PTR
+ && dominated_by_p (CDI_DOMINATORS, latch, header))
{
/* Shared headers should be eliminated by now. */
if (more_latches)
@@ -849,7 +844,6 @@ flow_loops_find (struct loops *loops, int flags)
flow_depth_first_order_compute (dfs_order, rc_order);
/* Save CFG derived information to avoid recomputing it. */
- loops->cfg.dom = dom;
loops->cfg.dfs_order = dfs_order;
loops->cfg.rc_order = rc_order;
@@ -878,7 +872,7 @@ flow_loops_find (struct loops *loops, int flags)
basic_block latch = e->src;
if (latch != ENTRY_BLOCK_PTR
- && dominated_by_p (dom, latch, header))
+ && dominated_by_p (CDI_DOMINATORS, latch, header))
{
loop->latch = latch;
break;
@@ -897,14 +891,13 @@ flow_loops_find (struct loops *loops, int flags)
/* Scan the loops. */
for (i = 1; i < num_loops; i++)
- flow_loop_scan (loops, loops->parray[i], flags);
+ flow_loop_scan (loops->parray[i], flags);
loops->num = num_loops;
}
else
{
- loops->cfg.dom = NULL;
- free_dominance_info (dom);
+ free_dominance_info (CDI_DOMINATORS);
}
loops->state = 0;
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index 0ab1590c4dd..4d8c67dd35d 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -230,9 +230,6 @@ struct loops
/* Information derived from the CFG. */
struct cfg
{
- /* The bitmap vector of dominators or NULL if not computed. */
- dominance_info dom;
-
/* The ordering of the basic blocks in a depth first search. */
int *dfs_order;
@@ -265,7 +262,7 @@ extern void flow_loops_dump (const struct loops *, FILE *,
void (*)(const struct loop *, FILE *, int), int);
extern void flow_loop_dump (const struct loop *, FILE *,
void (*)(const struct loop *, FILE *, int), int);
-extern int flow_loop_scan (struct loops *, struct loop *, int);
+extern int flow_loop_scan (struct loop *, int);
extern void flow_loop_free (struct loop *);
void mark_irreducible_loops (struct loops *);
@@ -292,7 +289,7 @@ extern void remove_bb_from_loops (basic_block);
extern void cancel_loop (struct loops *, struct loop *);
extern void cancel_loop_tree (struct loops *, struct loop *);
-extern basic_block loop_split_edge_with (edge, rtx, struct loops *);
+extern basic_block loop_split_edge_with (edge, rtx);
extern int fix_loop_placement (struct loop *);
enum
@@ -306,10 +303,9 @@ extern void force_single_succ_latches (struct loops *);
extern void verify_loop_structure (struct loops *);
/* Loop analysis. */
-extern bool simple_loop_p (struct loops *, struct loop *, struct loop_desc *);
+extern bool simple_loop_p (struct loop *, struct loop_desc *);
extern rtx count_loop_iterations (struct loop_desc *, rtx, rtx);
-extern bool just_once_each_iteration_p (struct loops *,struct loop *,
- basic_block);
+extern bool just_once_each_iteration_p (struct loop *, basic_block);
extern unsigned expected_loop_iterations (const struct loop *);
/* Loop manipulation. */
@@ -324,7 +320,7 @@ extern int duplicate_loop_to_header_edge (struct loop *, edge, struct loops *,
extern struct loop *loopify (struct loops *, edge, edge, basic_block);
extern void unloop (struct loops *, struct loop *);
extern bool remove_path (struct loops *, edge);
-extern edge split_loop_bb (struct loops *, basic_block, rtx);
+extern edge split_loop_bb (basic_block, rtx);
/* Loop optimizer initialization. */
extern struct loops *loop_optimizer_init (FILE *);
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index 3d6e69ef48d..fb5f8ae6c6b 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -39,14 +39,13 @@ static bool invariant_rtx_wrto_regs_p (rtx, regset);
static rtx test_for_iteration (struct loop_desc *desc, unsigned HOST_WIDE_INT);
static bool constant_iterations (struct loop_desc *, unsigned HOST_WIDE_INT *,
bool *);
-static bool simple_loop_exit_p (struct loops *, struct loop *, edge, regset,
+static bool simple_loop_exit_p (struct loop *, edge, regset,
rtx *, struct loop_desc *);
static rtx variable_initial_value (rtx, regset, rtx, rtx *, enum machine_mode);
static rtx variable_initial_values (edge, rtx, enum machine_mode);
static bool simple_condition_p (struct loop *, rtx, regset,
struct loop_desc *);
-static basic_block simple_increment (struct loops *, struct loop *, rtx *,
- struct loop_desc *);
+static basic_block simple_increment (struct loop *, rtx *, struct loop_desc *);
static rtx count_strange_loop_iterations (rtx, rtx, enum rtx_code,
int, rtx, enum machine_mode,
enum machine_mode);
@@ -73,10 +72,10 @@ inverse (unsigned HOST_WIDEST_INT x, int mod)
/* Checks whether BB is executed exactly once in each LOOP iteration. */
bool
-just_once_each_iteration_p (struct loops *loops, struct loop *loop, basic_block bb)
+just_once_each_iteration_p (struct loop *loop, basic_block bb)
{
/* It must be executed at least once each iteration. */
- if (!dominated_by_p (loops->cfg.dom, loop->latch, bb))
+ if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
return false;
/* And just once. */
@@ -295,8 +294,8 @@ simple_condition_p (struct loop *loop ATTRIBUTE_UNUSED, rtx condition,
iteration. Fills in DESC->stride and returns block in that DESC->var is
modified. */
static basic_block
-simple_increment (struct loops *loops, struct loop *loop,
- rtx *simple_increment_regs, struct loop_desc *desc)
+simple_increment (struct loop *loop, rtx *simple_increment_regs,
+ struct loop_desc *desc)
{
rtx mod_insn, mod_insn1, set, set_src, set_add;
basic_block mod_bb, mod_bb1;
@@ -308,7 +307,7 @@ simple_increment (struct loops *loops, struct loop *loop,
mod_bb = BLOCK_FOR_INSN (mod_insn);
/* Check that it is executed exactly once each iteration. */
- if (!just_once_each_iteration_p (loops, loop, mod_bb))
+ if (!just_once_each_iteration_p (loop, mod_bb))
return NULL;
/* mod_insn must be a simple increment/decrement. */
@@ -355,7 +354,7 @@ simple_increment (struct loops *loops, struct loop *loop,
return NULL;
mod_bb1 = BLOCK_FOR_INSN (mod_insn1);
- if (!dominated_by_p (loops->cfg.dom, mod_bb, mod_bb1))
+ if (!dominated_by_p (CDI_DOMINATORS, mod_bb, mod_bb1))
return NULL;
if (mod_bb1 == mod_bb)
{
@@ -962,7 +961,7 @@ test_for_iteration (struct loop_desc *desc, unsigned HOST_WIDE_INT iter)
description joined to it in in DESC. INVARIANT_REGS and SINGLE_SET_REGS
are results of blocks_{invariant,single_set}_regs over BODY. */
static bool
-simple_loop_exit_p (struct loops *loops, struct loop *loop, edge exit_edge,
+simple_loop_exit_p (struct loop *loop, edge exit_edge,
regset invariant_regs, rtx *single_set_regs,
struct loop_desc *desc)
{
@@ -979,7 +978,7 @@ simple_loop_exit_p (struct loops *loops, struct loop *loop, edge exit_edge,
return false;
/* It must be tested (at least) once during any iteration. */
- if (!dominated_by_p (loops->cfg.dom, loop->latch, exit_bb))
+ if (!dominated_by_p (CDI_DOMINATORS, loop->latch, exit_bb))
return false;
/* It must end in a simple conditional jump. */
@@ -1003,11 +1002,11 @@ simple_loop_exit_p (struct loops *loops, struct loop *loop, edge exit_edge,
/* Var must be simply incremented or decremented in exactly one insn that
is executed just once every iteration. */
- if (!(mod_bb = simple_increment (loops, loop, single_set_regs, desc)))
+ if (!(mod_bb = simple_increment (loop, single_set_regs, desc)))
return false;
/* OK, it is simple loop. Now just fill in remaining info. */
- desc->postincr = !dominated_by_p (loops->cfg.dom, exit_bb, mod_bb);
+ desc->postincr = !dominated_by_p (CDI_DOMINATORS, exit_bb, mod_bb);
desc->neg = !fallthru_out;
/* Find initial value of var and alternative values for lim. */
@@ -1026,7 +1025,7 @@ simple_loop_exit_p (struct loops *loops, struct loop *loop, edge exit_edge,
/* Tests whether LOOP is simple for loop. Returns simple loop description
in DESC. */
bool
-simple_loop_p (struct loops *loops, struct loop *loop, struct loop_desc *desc)
+simple_loop_p (struct loop *loop, struct loop_desc *desc)
{
unsigned i;
basic_block *body;
@@ -1051,7 +1050,7 @@ simple_loop_p (struct loops *loops, struct loop *loop, struct loop_desc *desc)
{
for (e = body[i]->succ; e; e = e->succ_next)
if (!flow_bb_inside_loop_p (loop, e->dest)
- && simple_loop_exit_p (loops, loop, e,
+ && simple_loop_exit_p (loop, e,
invariant_regs, single_set_regs, &act))
{
/* Prefer constant iterations; the less the better. */
@@ -1247,7 +1246,7 @@ mark_irreducible_loops (struct loops *loops)
: e->dest->index + 1;
if (closed[sidx])
{
- if (!closed[mri[sidx]])
+ if (mri[sidx] != -1 && !closed[mri[sidx]])
{
if (mr[sidx] < mr[idx])
{
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 6fa80c716aa..86af4a2536b 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -36,9 +36,9 @@ static void copy_loops_to (struct loops *, struct loop **, int,
struct loop *);
static void loop_redirect_edge (edge, basic_block);
static bool loop_delete_branch_edge (edge, int);
-static void remove_bbs (dominance_info, basic_block *, int);
+static void remove_bbs (basic_block *, int);
static bool rpe_enum_p (basic_block, void *);
-static int find_path (edge, dominance_info, basic_block **);
+static int find_path (edge, basic_block **);
static bool alp_enum_p (basic_block, void *);
static void add_loop (struct loops *, struct loop *);
static void fix_loop_placements (struct loop *);
@@ -47,17 +47,15 @@ static void fix_bb_placements (struct loops *, basic_block);
static void place_new_loop (struct loops *, struct loop *);
static void scale_loop_frequencies (struct loop *, int, int);
static void scale_bbs_frequencies (basic_block *, int, int, int);
-static basic_block create_preheader (struct loop *, dominance_info, int);
+static basic_block create_preheader (struct loop *, int);
static void fix_irreducible_loops (basic_block);
/* Splits basic block BB after INSN, returns created edge. Updates loops
and dominators. */
edge
-split_loop_bb (struct loops *loops, basic_block bb, rtx insn)
+split_loop_bb (basic_block bb, rtx insn)
{
edge e;
- basic_block *dom_bbs;
- int n_dom_bbs, i;
/* Split the block. */
e = split_block (bb, insn);
@@ -66,42 +64,31 @@ split_loop_bb (struct loops *loops, basic_block bb, rtx insn)
add_bb_to_loop (e->dest, e->src->loop_father);
/* Fix dominators. */
- add_to_dominance_info (loops->cfg.dom, e->dest);
- n_dom_bbs = get_dominated_by (loops->cfg.dom, e->src, &dom_bbs);
- for (i = 0; i < n_dom_bbs; i++)
- set_immediate_dominator (loops->cfg.dom, dom_bbs[i], e->dest);
- free (dom_bbs);
- set_immediate_dominator (loops->cfg.dom, e->dest, e->src);
+ add_to_dominance_info (CDI_DOMINATORS, e->dest);
+ redirect_immediate_dominators (CDI_DOMINATORS, e->src, e->dest);
+ set_immediate_dominator (CDI_DOMINATORS, e->dest, e->src);
return e;
}
-/* Checks whether basic block BB is dominated by RPE->DOM, where
- RPE is passed through DATA. */
-struct rpe_data
- {
- basic_block dom;
- dominance_info doms;
- };
-
+/* Checks whether basic block BB is dominated by DATA. */
static bool
rpe_enum_p (basic_block bb, void *data)
{
- struct rpe_data *rpe = data;
- return dominated_by_p (rpe->doms, bb, rpe->dom);
+ return dominated_by_p (CDI_DOMINATORS, bb, data);
}
/* Remove basic blocks BBS from loop structure and dominance info,
and delete them afterwards. */
static void
-remove_bbs (dominance_info dom, basic_block *bbs, int nbbs)
+remove_bbs (basic_block *bbs, int nbbs)
{
int i;
for (i = 0; i < nbbs; i++)
{
remove_bb_from_loops (bbs[i]);
- delete_from_dominance_info (dom, bbs[i]);
+ delete_from_dominance_info (CDI_DOMINATORS, bbs[i]);
delete_block (bbs[i]);
}
}
@@ -113,19 +100,15 @@ remove_bbs (dominance_info dom, basic_block *bbs, int nbbs)
alter anything by this function). The number of basic blocks in the
path is returned. */
static int
-find_path (edge e, dominance_info doms, basic_block **bbs)
+find_path (edge e, basic_block **bbs)
{
- struct rpe_data rpe;
-
if (e->dest->pred->pred_next)
abort ();
/* Find bbs in the path. */
- rpe.dom = e->dest;
- rpe.doms = doms;
*bbs = xcalloc (n_basic_blocks, sizeof (basic_block));
return dfs_enumerate_from (e->dest, 0, rpe_enum_p, *bbs,
- n_basic_blocks, &rpe);
+ n_basic_blocks, e->dest);
}
/* Fix placement of basic block BB inside loop hierarchy stored in LOOPS --
@@ -353,19 +336,19 @@ remove_path (struct loops *loops, edge e)
fix -- when e->dest has exactly one predecessor, this corresponds
to blocks dominated by e->dest, if not, split the edge. */
if (e->dest->pred->pred_next)
- e = loop_split_edge_with (e, NULL_RTX, loops)->pred;
+ e = loop_split_edge_with (e, NULL_RTX)->pred;
/* It may happen that by removing path we remove one or more loops
we belong to. In this case first unloop the loops, then proceed
normally. We may assume that e->dest is not a header of any loop,
as it now has exactly one predecessor. */
while (e->src->loop_father->outer
- && dominated_by_p (loops->cfg.dom,
+ && dominated_by_p (CDI_DOMINATORS,
e->src->loop_father->latch, e->dest))
unloop (loops, e->src->loop_father);
/* Identify the path. */
- nrem = find_path (e, loops->cfg.dom, &rem_bbs);
+ nrem = find_path (e, &rem_bbs);
n_bord_bbs = 0;
bord_bbs = xcalloc (n_basic_blocks, sizeof (basic_block));
@@ -397,7 +380,7 @@ remove_path (struct loops *loops, edge e)
if (rem_bbs[i]->loop_father->header == rem_bbs[i])
cancel_loop_tree (loops, rem_bbs[i]->loop_father);
- remove_bbs (loops->cfg.dom, rem_bbs, nrem);
+ remove_bbs (rem_bbs, nrem);
free (rem_bbs);
/* Find blocks whose dominators may be affected. */
@@ -405,25 +388,24 @@ remove_path (struct loops *loops, edge e)
sbitmap_zero (seen);
for (i = 0; i < n_bord_bbs; i++)
{
- int j, nldom;
- basic_block *ldom;
+ basic_block ldom;
- bb = get_immediate_dominator (loops->cfg.dom, bord_bbs[i]);
+ bb = get_immediate_dominator (CDI_DOMINATORS, bord_bbs[i]);
if (TEST_BIT (seen, bb->index))
continue;
SET_BIT (seen, bb->index);
- nldom = get_dominated_by (loops->cfg.dom, bb, &ldom);
- for (j = 0; j < nldom; j++)
- if (!dominated_by_p (loops->cfg.dom, from, ldom[j]))
- dom_bbs[n_dom_bbs++] = ldom[j];
- free(ldom);
+ for (ldom = first_dom_son (CDI_DOMINATORS, bb);
+ ldom;
+ ldom = next_dom_son (CDI_DOMINATORS, ldom))
+ if (!dominated_by_p (CDI_DOMINATORS, from, ldom))
+ dom_bbs[n_dom_bbs++] = ldom;
}
free (seen);
/* Recount dominators. */
- iterate_fix_dominators (loops->cfg.dom, dom_bbs, n_dom_bbs);
+ iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, n_dom_bbs);
free (dom_bbs);
/* These blocks have lost some predecessor(s), thus their irreducible
@@ -513,7 +495,7 @@ loopify (struct loops *loops, edge latch_edge, edge header_edge, basic_block swi
basic_block succ_bb = latch_edge->dest;
basic_block pred_bb = header_edge->src;
basic_block *dom_bbs, *body;
- unsigned n_dom_bbs, i, j;
+ unsigned n_dom_bbs, i;
sbitmap seen;
struct loop *loop = xcalloc (1, sizeof (struct loop));
struct loop *outer = succ_bb->loop_father->outer;
@@ -538,9 +520,9 @@ loopify (struct loops *loops, edge latch_edge, edge header_edge, basic_block swi
loop_redirect_edge (switch_bb->succ, succ_bb);
/* Update dominators. */
- set_immediate_dominator (loops->cfg.dom, switch_bb, pred_bb);
- set_immediate_dominator (loops->cfg.dom, loop->header, switch_bb);
- set_immediate_dominator (loops->cfg.dom, succ_bb, switch_bb);
+ set_immediate_dominator (CDI_DOMINATORS, switch_bb, pred_bb);
+ set_immediate_dominator (CDI_DOMINATORS, loop->header, switch_bb);
+ set_immediate_dominator (CDI_DOMINATORS, succ_bb, switch_bb);
/* Compute new loop. */
add_loop (loops, loop);
@@ -569,20 +551,19 @@ loopify (struct loops *loops, edge latch_edge, edge header_edge, basic_block swi
for (i = 0; i < loop->num_nodes; i++)
{
- unsigned nldom;
- basic_block *ldom;
+ basic_block ldom;
- nldom = get_dominated_by (loops->cfg.dom, body[i], &ldom);
- for (j = 0; j < nldom; j++)
- if (!TEST_BIT (seen, ldom[j]->index))
+ for (ldom = first_dom_son (CDI_DOMINATORS, body[i]);
+ ldom;
+ ldom = next_dom_son (CDI_DOMINATORS, ldom))
+ if (!TEST_BIT (seen, ldom->index))
{
- SET_BIT (seen, ldom[j]->index);
- dom_bbs[n_dom_bbs++] = ldom[j];
+ SET_BIT (seen, ldom->index);
+ dom_bbs[n_dom_bbs++] = ldom;
}
- free (ldom);
}
- iterate_fix_dominators (loops->cfg.dom, dom_bbs, n_dom_bbs);
+ iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, n_dom_bbs);
free (body);
free (seen);
@@ -990,7 +971,7 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, struct loops *loops,
copy_loops_to (loops, orig_loops, n_orig_loops, target);
/* Copy bbs. */
- copy_bbs (bbs, n, new_bbs, spec_edges, 2, new_spec_edges, loop, loops);
+ copy_bbs (bbs, n, new_bbs, spec_edges, 2, new_spec_edges, loop);
/* Note whether the blocks and edges belong to an irreducible loop. */
if (add_irreducible_flag)
@@ -1019,7 +1000,7 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, struct loops *loops,
redirect_edge_and_branch_force (latch_edge, new_bbs[0]);
redirect_edge_and_branch_force (new_spec_edges[SE_LATCH],
loop->header);
- set_immediate_dominator (loops->cfg.dom, new_bbs[0], latch);
+ set_immediate_dominator (CDI_DOMINATORS, new_bbs[0], latch);
latch = loop->latch = new_bbs[1];
e = latch_edge = new_spec_edges[SE_LATCH];
}
@@ -1028,7 +1009,7 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, struct loops *loops,
redirect_edge_and_branch_force (new_spec_edges[SE_LATCH],
loop->header);
redirect_edge_and_branch_force (e, new_bbs[0]);
- set_immediate_dominator (loops->cfg.dom, new_bbs[0], e->src);
+ set_immediate_dominator (CDI_DOMINATORS, new_bbs[0], e->src);
e = new_spec_edges[SE_LATCH];
}
@@ -1056,7 +1037,7 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, struct loops *loops,
/* Update the original loop. */
if (!is_latch)
- set_immediate_dominator (loops->cfg.dom, e->dest, e->src);
+ set_immediate_dominator (CDI_DOMINATORS, e->dest, e->src);
if (flags & DLTHE_FLAG_UPDATE_FREQ)
{
scale_bbs_frequencies (bbs, n, scale_main, REG_BR_PROB_BASE);
@@ -1070,15 +1051,15 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, struct loops *loops,
int n_dom_bbs,j;
bb = bbs[i];
- n_dom_bbs = get_dominated_by (loops->cfg.dom, bb, &dom_bbs);
+ n_dom_bbs = get_dominated_by (CDI_DOMINATORS, bb, &dom_bbs);
for (j = 0; j < n_dom_bbs; j++)
{
dominated = dom_bbs[j];
if (flow_bb_inside_loop_p (loop, dominated))
continue;
dom_bb = nearest_common_dominator (
- loops->cfg.dom, first_active[i], first_active_latch);
- set_immediate_dominator (loops->cfg.dom, dominated, dom_bb);
+ CDI_DOMINATORS, first_active[i], first_active_latch);
+ set_immediate_dominator (CDI_DOMINATORS, dominated, dom_bb);
}
free (dom_bbs);
}
@@ -1094,7 +1075,7 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, struct loops *loops,
entry; otherwise we also force preheader block to have only one successor.
The function also updates dominators stored in DOM. */
static basic_block
-create_preheader (struct loop *loop, dominance_info dom, int flags)
+create_preheader (struct loop *loop, int flags)
{
edge e, fallthru;
basic_block dummy;
@@ -1141,7 +1122,7 @@ create_preheader (struct loop *loop, dominance_info dom, int flags)
if (ploop->latch == dummy)
ploop->latch = fallthru->dest;
- add_to_dominance_info (dom, fallthru->dest);
+ add_to_dominance_info (CDI_DOMINATORS, fallthru->dest);
/* Redirect edges. */
for (e = dummy->pred; e; e = e->pred_next)
@@ -1159,15 +1140,15 @@ create_preheader (struct loop *loop, dominance_info dom, int flags)
jump = redirect_edge_and_branch_force (e, loop->header);
if (jump)
{
- add_to_dominance_info (dom, jump);
- set_immediate_dominator (dom, jump, src);
+ add_to_dominance_info (CDI_DOMINATORS, jump);
+ set_immediate_dominator (CDI_DOMINATORS, jump, src);
add_bb_to_loop (jump, loop);
loop->latch = jump;
}
/* Update structures. */
- redirect_immediate_dominators (dom, dummy, loop->header);
- set_immediate_dominator (dom, loop->header, dummy);
+ redirect_immediate_dominators (CDI_DOMINATORS, dummy, loop->header);
+ set_immediate_dominator (CDI_DOMINATORS, loop->header, dummy);
loop->header->loop_father = loop;
add_bb_to_loop (dummy, cloop);
if (rtl_dump_file)
@@ -1184,7 +1165,7 @@ create_preheaders (struct loops *loops, int flags)
{
unsigned i;
for (i = 1; i < loops->num; i++)
- create_preheader (loops->parray[i], loops->cfg.dom, flags);
+ create_preheader (loops->parray[i], flags);
loops->state |= LOOPS_HAVE_PREHEADERS;
}
@@ -1207,7 +1188,7 @@ force_single_succ_latches (struct loops *loops)
for (e = loop->header->pred; e->src != loop->latch; e = e->pred_next)
continue;
- loop_split_edge_with (e, NULL_RTX, loops);
+ loop_split_edge_with (e, NULL_RTX);
}
loops->state |= LOOPS_HAVE_SIMPLE_LATCHES;
}
@@ -1217,7 +1198,7 @@ force_single_succ_latches (struct loops *loops)
be ok after this function. The created block is placed on correct place
in LOOPS structure and its dominator is set. */
basic_block
-loop_split_edge_with (edge e, rtx insns, struct loops *loops)
+loop_split_edge_with (edge e, rtx insns)
{
basic_block src, dest, new_bb;
struct loop *loop_c;
@@ -1231,7 +1212,7 @@ loop_split_edge_with (edge e, rtx insns, struct loops *loops)
/* Create basic block for it. */
new_bb = split_edge (e);
- add_to_dominance_info (loops->cfg.dom, new_bb);
+ add_to_dominance_info (CDI_DOMINATORS, new_bb);
add_bb_to_loop (new_bb, loop_c);
new_bb->flags = insns ? BB_SUPERBLOCK : 0;
@@ -1245,9 +1226,9 @@ loop_split_edge_with (edge e, rtx insns, struct loops *loops)
if (insns)
emit_insn_after (insns, BB_END (new_bb));
- set_immediate_dominator (loops->cfg.dom, new_bb, src);
- set_immediate_dominator (loops->cfg.dom, dest,
- recount_dominator (loops->cfg.dom, dest));
+ set_immediate_dominator (CDI_DOMINATORS, new_bb, src);
+ set_immediate_dominator (CDI_DOMINATORS, dest,
+ recount_dominator (CDI_DOMINATORS, dest));
if (dest->loop_father->latch == src)
dest->loop_father->latch = new_bb;
diff --git a/gcc/common.opt b/gcc/common.opt
index a3dc84e75ed..302dfac6709 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -513,6 +513,14 @@ fprofile-arcs
Common
Insert arc-based program profiling code
+fprofile-generate
+Common
+Enable common options for generating profile info for profile feedback directed optimizations
+
+fprofile-use
+Common
+Enable common options for performing profile feedback directed optimizations
+
fprofile-values
Common
Insert code to profile values of expressions
@@ -735,14 +743,6 @@ gcoff
Common JoinedOrMissing
Generate debug information in COFF format
-gdwarf
-Common JoinedOrMissing
-Generate debug information in DWARF v1 format
-
-gdwarf+
-Common JoinedOrMissing
-Generate debug information in extended DWARF v1 format
-
gdwarf-2
Common JoinedOrMissing
Generate debug information in DWARF v2 format
diff --git a/gcc/config/alpha/alpha-modes.def b/gcc/config/alpha/alpha-modes.def
index b3747a1dae8..8e9e6984bd2 100644
--- a/gcc/config/alpha/alpha-modes.def
+++ b/gcc/config/alpha/alpha-modes.def
@@ -19,5 +19,5 @@ the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* 128-bit floating point. This gets reset in alpha_override_options
- if VAX float format is in use. */
+ if VAX float format is in use. */
FLOAT_MODE (TF, 16, ieee_quad_format);
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 88307170c9f..9d7da136499 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -5125,7 +5125,7 @@ alpha_multipass_dfa_lookahead (void)
struct machine_function GTY(())
{
- /* For unicosmk. */
+ /* For unicosmk. */
/* List of call information words for calls from this function. */
struct rtx_def *first_ciw;
struct rtx_def *last_ciw;
@@ -5134,7 +5134,7 @@ struct machine_function GTY(())
/* List of deferred case vectors. */
struct rtx_def *addr_list;
- /* For OSF. */
+ /* For OSF. */
const char *some_ld_name;
};
diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h
index 2855351e9fa..fac277240a3 100644
--- a/gcc/config/alpha/alpha.h
+++ b/gcc/config/alpha/alpha.h
@@ -818,7 +818,7 @@ enum reg_class {
'U' is a symbolic operand.
- 'W' is a vector zero. */
+ 'W' is a vector zero. */
#define EXTRA_CONSTRAINT alpha_extra_constraint
diff --git a/gcc/config/alpha/elf.h b/gcc/config/alpha/elf.h
index 7115bc0706b..34bba3ecb17 100644
--- a/gcc/config/alpha/elf.h
+++ b/gcc/config/alpha/elf.h
@@ -18,7 +18,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+Boston, MA 02111-1307, USA. */
#undef OBJECT_FORMAT_COFF
#undef EXTENDED_COFF
@@ -389,7 +389,7 @@ void FN (void) \
/* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
(even more) magical crtbegin.o file which provides part of the
support for getting C++ file-scope static object constructed
- before entering `main'. */
+ before entering `main'. */
#undef STARTFILE_SPEC
#ifdef HAVE_LD_PIE
diff --git a/gcc/config/alpha/lib1funcs.asm b/gcc/config/alpha/lib1funcs.asm
index 6bea231bc06..a2abb1f8ae4 100644
--- a/gcc/config/alpha/lib1funcs.asm
+++ b/gcc/config/alpha/lib1funcs.asm
@@ -307,7 +307,7 @@ $46:
conventions. */
#if TYPE == UNSIGNED && SIZE == 32
/* This could be avoided by adding some CPP hair to the divide loop.
- It is probably not worth the added complexity. */
+ It is probably not worth the added complexity. */
addl RETREG,0,RETREG
#endif
diff --git a/gcc/config/alpha/openbsd.h b/gcc/config/alpha/openbsd.h
index 45f627de142..b9df2e4255c 100644
--- a/gcc/config/alpha/openbsd.h
+++ b/gcc/config/alpha/openbsd.h
@@ -72,7 +72,7 @@ Boston, MA 02111-1307, USA. */
/* Assembler format: exception region output. */
/* All configurations that don't use elf must be explicit about not using
- dwarf unwind information. */
+ dwarf unwind information. */
#ifdef INCOMING_RETURN_ADDR_RTX
#undef DWARF2_UNWIND_INFO
#define DWARF2_UNWIND_INFO 0
diff --git a/gcc/config/alpha/unicosmk.h b/gcc/config/alpha/unicosmk.h
index 5a74582c46d..5f75bbb87af 100644
--- a/gcc/config/alpha/unicosmk.h
+++ b/gcc/config/alpha/unicosmk.h
@@ -480,7 +480,6 @@ ssib_section (void) \
#undef SDB_DEBUGGING_INFO
#undef MIPS_DEBUGGING_INFO
#undef DBX_DEBUGGING_INFO
-#undef DWARF_DEBUGGING_INFO
#undef DWARF2_DEBUGGING_INFO
#undef DWARF2_UNWIND_INFO
#undef INCOMING_RETURN_ADDR_RTX
diff --git a/gcc/config/alpha/vms-cc.c b/gcc/config/alpha/vms-cc.c
index 8dd12da9f43..672a30fe468 100644
--- a/gcc/config/alpha/vms-cc.c
+++ b/gcc/config/alpha/vms-cc.c
@@ -49,22 +49,22 @@ static char *default_defines = (char *) "";
static char *defines;
/* Translate a Unix syntax directory specification into VMS syntax.
- If indicators of VMS syntax found, return input string. */
+ If indicators of VMS syntax found, return input string. */
static char *to_host_dir_spec (char *);
/* Translate a Unix syntax file specification into VMS syntax.
- If indicators of VMS syntax found, return input string. */
+ If indicators of VMS syntax found, return input string. */
static char *to_host_file_spec (char *);
-/* Add a translated arg to the list to be passed to DEC CC */
+/* Add a translated arg to the list to be passed to DEC CC. */
static void addarg (const char *);
/* Preprocess the number of args in P_ARGC and contained in ARGV.
- Look for special flags, etc. that must be handled first. */
+ Look for special flags, etc. that must be handled first. */
static void preprocess_args (int *, char **);
/* Process the number of args in P_ARGC and contained in ARGV. Look
- for special flags, etc. that must be handled for the VMS compiler. */
+ for special flags, etc. that must be handled for the VMS compiler. */
static void process_args (int *, char **);
/* Action routine called by decc$to_vms */
diff --git a/gcc/config/alpha/vms-crt0-64.c b/gcc/config/alpha/vms-crt0-64.c
index 845059c83cd..9792f9205a5 100644
--- a/gcc/config/alpha/vms-crt0-64.c
+++ b/gcc/config/alpha/vms-crt0-64.c
@@ -77,7 +77,7 @@ __main (arg1, arg2, arg3, image_file_desc, arg5, arg6)
#pragma __pointer_size long
- /* Reallocate argv with 64 bit pointers. */
+ /* Reallocate argv with 64 bit pointers. */
long_argv = (char **) malloc (sizeof (char *) * (argc + 1));
for (i = 0; i < argc; i++)
diff --git a/gcc/config/alpha/vms-crt0.c b/gcc/config/alpha/vms-crt0.c
index a3c1310da0d..88896c63af7 100644
--- a/gcc/config/alpha/vms-crt0.c
+++ b/gcc/config/alpha/vms-crt0.c
@@ -33,7 +33,7 @@ You Lose! This file can only be compiled with DEC C.
#else
/* This file can only be compiled with DEC C, due to the call to
- lib$establish. */
+ lib$establish. */
#include <stdlib.h>
#include <string.h>
diff --git a/gcc/config/alpha/vms-ld.c b/gcc/config/alpha/vms-ld.c
index bb7495ed14d..cb1d4c93faa 100644
--- a/gcc/config/alpha/vms-ld.c
+++ b/gcc/config/alpha/vms-ld.c
@@ -44,7 +44,7 @@ static char *vmsdwarf2spec = 0;
/* File specification for vms-dwarf2eh.o. */
static char *vmsdwarf2ehspec = 0;
-/* verbose = 1 if -v passed. */
+/* verbose = 1 if -v passed. */
static int verbose = 0;
/* save_temps = 1 if -save-temps passed. */
@@ -95,10 +95,10 @@ static void addarg (const char *);
static int is_regular_file (char *);
/* Translate a Unix syntax file specification FILESPEC into VMS syntax.
- If indicators of VMS syntax found, return input string. */
+ If indicators of VMS syntax found, return input string. */
static char *to_host_file_spec (char *);
-/* Locate the library named LIB_NAME in the set of paths PATH_VAL. */
+/* Locate the library named LIB_NAME in the set of paths PATH_VAL. */
static char *locate_lib (char *, char *);
/* Given a library name NAME, i.e. foo, Look for libfoo.lib and then
@@ -106,15 +106,15 @@ static char *locate_lib (char *, char *);
static const char *expand_lib (char *);
/* Preprocess the number of args P_ARGC in ARGV.
- Look for special flags, etc. that must be handled first. */
+ Look for special flags, etc. that must be handled first. */
static void preprocess_args (int *, char **);
/* Preprocess the number of args P_ARGC in ARGV. Look for
- special flags, etc. that must be handled for the VMS linker. */
+ special flags, etc. that must be handled for the VMS linker. */
static void process_args (int *, char **);
/* Action routine called by decc$to_vms. NAME is a file name or
- directory name. TYPE is unused. */
+ directory name. TYPE is unused. */
static int translate_unix (char *, int);
int main (int, char **);
diff --git a/gcc/config/alpha/vms-psxcrt0-64.c b/gcc/config/alpha/vms-psxcrt0-64.c
index 7f93392e484..8ca9e1d07b5 100644
--- a/gcc/config/alpha/vms-psxcrt0-64.c
+++ b/gcc/config/alpha/vms-psxcrt0-64.c
@@ -79,7 +79,7 @@ __main (arg1, arg2, arg3, image_file_desc, arg5, arg6)
#pragma __pointer_size long
- /* Reallocate argv with 64 bit pointers. */
+ /* Reallocate argv with 64 bit pointers. */
long_argv = (char **) malloc (sizeof (char *) * (argc + 1));
for (i = 0; i < argc; i++)
diff --git a/gcc/config/alpha/vms-psxcrt0.c b/gcc/config/alpha/vms-psxcrt0.c
index 1b51f6d2172..65962ee2219 100644
--- a/gcc/config/alpha/vms-psxcrt0.c
+++ b/gcc/config/alpha/vms-psxcrt0.c
@@ -33,7 +33,7 @@ You Lose! This file can only be compiled with DEC C.
#else
/* This file can only be compiled with DEC C, due to the call to
- lib$establish. */
+ lib$establish. */
#include <stdlib.h>
#include <string.h>
diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h
index 192e178bd33..338ed559a32 100644
--- a/gcc/config/alpha/vms.h
+++ b/gcc/config/alpha/vms.h
@@ -422,7 +422,7 @@ do { \
}
/* Link with vms-dwarf2.o if -g (except -g0). This causes the
- VMS link to pull all the dwarf2 debug sections together. */
+ VMS link to pull all the dwarf2 debug sections together. */
#undef LINK_SPEC
#define LINK_SPEC "%{g:-g vms-dwarf2.o%s} %{g0} %{g1:-g1 vms-dwarf2.o%s} \
%{g2:-g2 vms-dwarf2.o%s} %{g3:-g3 vms-dwarf2.o%s} %{shared} %{v} %{map}"
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 7cf119ec9a2..876bef56828 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -1047,7 +1047,7 @@ arc_compute_function_type (tree decl)
SIZE is the size needed for local variables. */
unsigned int
-arc_compute_frame_size (int size /* # of var. bytes allocated. */)
+arc_compute_frame_size (int size /* # of var. bytes allocated. */)
{
int regno;
unsigned int total_size, var_size, args_size, pretend_size, extra_size;
diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
index 2135c6c057d..5a5f168a83c 100644
--- a/gcc/config/arc/arc.h
+++ b/gcc/config/arc/arc.h
@@ -1245,7 +1245,6 @@ do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", 1 << (LOG)); } while (0)
/* Generate DBX and DWARF debugging information. */
#define DBX_DEBUGGING_INFO 1
-#define DWARF_DEBUGGING_INFO 1
/* Prefer STABS (for now). */
#undef PREFERRED_DEBUGGING_TYPE
diff --git a/gcc/config/arm/aof.h b/gcc/config/arm/aof.h
index 2650a0eedd2..5a6ab2c0e2c 100644
--- a/gcc/config/arm/aof.h
+++ b/gcc/config/arm/aof.h
@@ -133,7 +133,7 @@
/* Some systems use __main in a way incompatible with its use in gcc, in these
cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
give the same symbol without quotes for an alternative entry point. You
- must define both, or neither. */
+ must define both, or neither. */
#define NAME__MAIN "__gccmain"
#define SYMBOL__MAIN __gccmain
@@ -290,7 +290,7 @@ do { \
#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
fprintf ((STREAM), "\tDCD\t|L..%d|\n", (VALUE))
-/* A label marking the start of a jump table is a data label. */
+/* A label marking the start of a jump table is a data label. */
#define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE) \
fprintf ((STREAM), "\tALIGN\n|%s..%d|\n", (PREFIX), (NUM))
diff --git a/gcc/config/arm/arm-modes.def b/gcc/config/arm/arm-modes.def
index 1d58b18bb23..b8535519141 100644
--- a/gcc/config/arm/arm-modes.def
+++ b/gcc/config/arm/arm-modes.def
@@ -31,7 +31,7 @@ FLOAT_MODE (XF, 12, 0);
CC_NOOVmode should be used with SImode integer equalities.
CC_Zmode should be used if only the Z flag is set correctly
CC_Nmode should be used if only the N (sign) flag is set correctly
- CCmode should be used otherwise. */
+ CCmode should be used otherwise. */
CC_MODE (CC_NOOV);
CC_MODE (CC_Z);
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 44e27bb1ecb..ba2491e3bb8 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -934,7 +934,7 @@ arm_override_options (void)
arm_constant_limit = 1;
/* If optimizing for size, bump the number of instructions that we
- are prepared to conditionally execute (even on a StrongARM). */
+ are prepared to conditionally execute (even on a StrongARM). */
max_insns_skipped = 6;
}
else
@@ -947,7 +947,7 @@ arm_override_options (void)
/* On XScale the longer latency of a load makes it more difficult
to achieve a good schedule, so it's faster to synthesize
- constants that can be done in two insns. */
+ constants that can be done in two insns. */
if (arm_tune_xscale)
arm_constant_limit = 2;
@@ -1141,13 +1141,13 @@ use_return_insn (int iscond, rtx sibling)
if (stack_adjust == 4 && !arm_arch5)
{
/* Validate that r3 is a call-clobbered register (always true in
- the default abi) ... */
+ the default abi) ... */
if (!call_used_regs[3])
return 0;
/* ... that it isn't being used for a return value (always true
until we implement return-in-regs), or for a tail-call
- argument ... */
+ argument ... */
if (sibling)
{
if (GET_CODE (sibling) != CALL_INSN)
@@ -2088,7 +2088,7 @@ arm_return_in_memory (tree type)
return 1;
}
-/* Indicate whether or not words of a double are in big-endian order. */
+/* Indicate whether or not words of a double are in big-endian order. */
int
arm_float_words_big_endian (void)
@@ -3811,7 +3811,7 @@ arm_9e_rtx_costs (rtx x, int code, int outer_code, int *total)
/* All address computations that can be done are free, but rtx cost returns
the same for practically all of them. So we weight the different types
of address here in the order (most pref first):
- PRE/POST_INC/DEC, SHIFT or NON-INT sum, INT sum, REG, MEM or LABEL. */
+ PRE/POST_INC/DEC, SHIFT or NON-INT sum, INT sum, REG, MEM or LABEL. */
static inline int
arm_arm_address_cost (rtx x)
{
@@ -8306,7 +8306,7 @@ output_ascii_pseudo_op (FILE *stream, const unsigned char *p, int len)
case '\\':
putc ('\\', stream);
len_so_far++;
- /* drop through. */
+ /* Drop through. */
default:
if (c >= ' ' && c <= '~')
@@ -10127,7 +10127,7 @@ arm_assemble_integer (rtx x, unsigned int size, int aligned_p)
output_addr_const (asm_out_file, x);
/* Mark symbols as position independent. We only do this in the
- .text segment, not in the .data segment. */
+ .text segment, not in the .data segment. */
if (NEED_GOT_RELOC && flag_pic && making_const_table &&
(GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == LABEL_REF))
{
@@ -10638,7 +10638,7 @@ arm_final_prescan_insn (rtx insn)
}
if (!this_insn)
{
- /* Oh, dear! we ran off the end.. give up */
+ /* Oh, dear! we ran off the end.. give up. */
recog (PATTERN (insn), insn, NULL);
arm_ccfsm_state = 0;
arm_target_insn = NULL;
@@ -10815,7 +10815,7 @@ arm_debugger_arg_offset (int value, rtx addr)
which is the frame pointer
a constant integer
- then... */
+ then... */
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
{
@@ -12143,7 +12143,7 @@ is_called_in_ARM_mode (tree func)
#endif
}
-/* The bits which aren't usefully expanded as rtl. */
+/* The bits which aren't usefully expanded as rtl. */
const char *
thumb_unexpanded_epilogue (void)
{
@@ -12228,7 +12228,7 @@ thumb_unexpanded_epilogue (void)
mask &= (2 << regno) - 1; /* A noop if regno == 8 */
- /* Pop the values into the low register(s). */
+ /* Pop the values into the low register(s). */
thumb_pushpop (asm_out_file, mask, 0);
/* Move the value(s) into the high registers. */
@@ -12256,7 +12256,7 @@ thumb_unexpanded_epilogue (void)
{
/* The stack backtrace structure creation code had to
push R7 in order to get a work register, so we pop
- it now. */
+ it now. */
live_regs_mask |= (1 << LAST_LO_REGNUM);
}
@@ -12611,7 +12611,7 @@ thumb_output_function_prologue (FILE *f, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
the assembler to bypass the ARM code when this function
is called from a Thumb encoded function elsewhere in the
same file. Hence the definition of STUB_NAME here must
- agree with the definition in gas/config/tc-arm.c */
+ agree with the definition in gas/config/tc-arm.c. */
#define STUB_NAME ".real_start_of"
@@ -12686,7 +12686,7 @@ thumb_output_function_prologue (FILE *f, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
if (regs_ever_live [LAST_ARG_REGNUM] == 0)
work_register = LAST_ARG_REGNUM;
- else /* We must push a register of our own */
+ else /* We must push a register of our own. */
live_regs_mask |= (1 << LAST_LO_REGNUM);
}
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index 7c3b47a6e97..62aa710a66b 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -147,12 +147,12 @@ extern GTY(()) rtx arm_compare_op1;
/* The label of the current constant pool. */
extern rtx pool_vector_label;
/* Set to 1 when a return insn is output, this means that the epilogue
- is not needed. */
+ is not needed. */
extern int return_used_this_function;
/* Used to produce AOF syntax assembler. */
extern GTY(()) rtx aof_pic_label;
-/* Just in case configure has failed to define anything. */
+/* Just in case configure has failed to define anything. */
#ifndef TARGET_CPU_DEFAULT
#define TARGET_CPU_DEFAULT TARGET_CPU_generic
#endif
@@ -407,7 +407,7 @@ extern GTY(()) rtx aof_pic_label;
function tries to return. */
#define ARM_FLAG_ABORT_NORETURN (1 << 13)
-/* Nonzero if function prologues should not load the PIC register. */
+/* Nonzero if function prologues should not load the PIC register. */
#define ARM_FLAG_SINGLE_PIC_BASE (1 << 14)
/* Nonzero if all call instructions should be indirect. */
@@ -611,7 +611,7 @@ enum prog_mode_type
prog_mode32
};
-/* Recast the program mode class to be the prog_mode attribute */
+/* Recast the program mode class to be the prog_mode attribute. */
#define arm_prog_mode ((enum attr_prog_mode) arm_prgmode)
extern enum prog_mode_type arm_prgmode;
@@ -992,7 +992,7 @@ extern const char * structure_size_string;
and the register where structure-value addresses are passed.
Aside from that, you can include as many other registers as you like.
The CC is not preserved over function calls on the ARM 6, so it is
- easier to assume this for all. SFP is preserved, since FP is. */
+ easier to assume this for all. SFP is preserved, since FP is. */
#define CALL_USED_REGISTERS \
{ \
1,1,1,1,0,0,0,0, \
@@ -1025,7 +1025,7 @@ extern const char * structure_size_string;
{ \
/* When optimizing for size, it's better not to use \
the HI regs, because of the overhead of stacking \
- them. */ \
+ them. */ \
for (regno = FIRST_HI_REGNUM; \
regno <= LAST_HI_REGNUM; ++regno) \
fixed_regs[regno] = call_used_regs[regno] = 1; \
@@ -1305,7 +1305,7 @@ enum reg_class
#define N_REG_CLASSES (int) LIM_REG_CLASSES
-/* Give names of register classes as strings for dump file. */
+/* Give names of register classes as strings for dump file. */
#define REG_CLASS_NAMES \
{ \
"NO_REGS", \
@@ -1369,7 +1369,7 @@ enum reg_class
/* When SMALL_REGISTER_CLASSES is nonzero, the compiler allows
registers explicitly used in the rtl to be used as spill registers
but prevents the compiler from extending the lifetime of these
- registers. */
+ registers. */
#define SMALL_REGISTER_CLASSES TARGET_THUMB
/* Get reg_class from a letter such as appears in the machine description.
@@ -1436,7 +1436,7 @@ enum reg_class
an offset from a register.
`S' means any symbol that has the SYMBOL_REF_FLAG set or a CONSTANT_POOL
address. This means that the symbol is in the text segment and can be
- accessed without using a load. */
+ accessed without using a load. */
#define EXTRA_CONSTRAINT_ARM(OP, C) \
((C) == 'Q' ? GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG : \
@@ -1487,7 +1487,7 @@ enum reg_class
? GENERAL_REGS : NO_REGS) \
: THUMB_SECONDARY_OUTPUT_RELOAD_CLASS (CLASS, MODE, X))
-/* If we need to load shorts byte-at-a-time, then we need a scratch. */
+/* If we need to load shorts byte-at-a-time, then we need a scratch. */
#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
/* Cannot load constants into Cirrus registers. */ \
((TARGET_MAVERICK && TARGET_HARD_FLOAT \
@@ -1642,7 +1642,7 @@ enum reg_class
/* If we generate an insn to push BYTES bytes,
this says how many the stack pointer really advances by. */
/* The push insns do not do this rounding implicitly.
- So don't define this. */
+ So don't define this. */
/* #define PUSH_ROUNDING(NPUSHED) ROUND_UP_WORD (NPUSHED) */
/* Define this if the maximum size of all the outgoing args is to be
@@ -1697,12 +1697,12 @@ enum reg_class
/* How large values are returned */
/* A C expression which can inhibit the returning of certain function values
- in registers, based on the type of value. */
+ in registers, based on the type of value. */
#define RETURN_IN_MEMORY(TYPE) arm_return_in_memory (TYPE)
/* Define DEFAULT_PCC_STRUCT_RETURN to 1 if all structure and union return
values must be in memory. On the ARM, they need only do so if larger
- than a word, or if they contain elements offset from zero in the struct. */
+ than a word, or if they contain elements offset from zero in the struct. */
#define DEFAULT_PCC_STRUCT_RETURN 0
/* Flags for the call/call_value rtl operations set up by function_arg. */
@@ -1736,7 +1736,7 @@ enum reg_class
#define ARM_FT_INTERRUPT (1 << 2) /* Note overlap with FT_ISR and above. */
#define ARM_FT_NAKED (1 << 3) /* No prologue or epilogue. */
#define ARM_FT_VOLATILE (1 << 4) /* Does not return. */
-#define ARM_FT_NESTED (1 << 5) /* Embedded inside another func. */
+#define ARM_FT_NESTED (1 << 5) /* Embedded inside another func. */
/* Some macros to test these flags. */
#define ARM_FUNC_TYPE(t) (t & ARM_FT_TYPE_MASK)
@@ -1780,7 +1780,7 @@ typedef struct
int iwmmxt_nregs;
int named_count;
int nargs;
- /* One of CALL_NORMAL, CALL_LONG or CALL_SHORT . */
+ /* One of CALL_NORMAL, CALL_LONG or CALL_SHORT. */
int call_cookie;
} CUMULATIVE_ARGS;
@@ -2132,7 +2132,7 @@ typedef struct
They give nonzero only if REGNO is a hard reg of the suitable class
or a pseudo reg currently allocated to a suitable hard reg.
Since they use reg_renumber, they are safe only once reg_renumber
- has been allocated, which happens in local-alloc.c. */
+ has been allocated, which happens in local-alloc.c. */
#define TEST_REGNO(R, TEST, VALUE) \
((R TEST VALUE) || ((unsigned) reg_renumber[R] TEST VALUE))
@@ -2158,7 +2158,7 @@ typedef struct
REGNO_MODE_OK_FOR_BASE_P (REGNO, QImode)
/* Maximum number of registers that can appear in a valid memory address.
- Shifts in addresses can't be by a register. */
+ Shifts in addresses can't be by a register. */
#define MAX_REGS_PER_ADDRESS 2
/* Recognize any constant value that is a valid address. */
@@ -2366,7 +2366,7 @@ do { \
/* Define as C expression which evaluates to nonzero if the tablejump
instruction expects the table to contain offsets from the address of the
table.
- Do not define this if the table should contain absolute addresses. */
+ Do not define this if the table should contain absolute addresses. */
/* #define CASE_VECTOR_PC_RELATIVE 1 */
/* signed 'char' is most compatible, but RISC OS wants it unsigned.
@@ -2411,7 +2411,7 @@ do { \
/* This is all wrong. Defining SHIFT_COUNT_TRUNCATED tells combine that
code like (X << (Y % 32)) for register X, Y is equivalent to (X << Y).
On the arm, Y in a register is used modulo 256 for the shift. Only for
- rotates is modulo 32 used. */
+ rotates is modulo 32 used. */
/* #define SHIFT_COUNT_TRUNCATED 1 */
/* All integers have the same format so truncation is easy. */
@@ -2479,7 +2479,7 @@ extern int making_const_table;
c_register_pragma (0, "long_calls_off", arm_pr_long_calls_off); \
} while (0)
-/* Condition code information. */
+/* Condition code information. */
/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
return the mode to be used for the comparison. */
@@ -2631,8 +2631,8 @@ extern int making_const_table;
HOST_WIDE_INT offset = 0; \
if (GET_CODE (base) != REG) \
{ \
- /* Ensure that BASE is a register */ \
- /* (one of them must be). */ \
+ /* Ensure that BASE is a register. */ \
+ /* (one of them must be). */ \
rtx temp = base; \
base = index; \
index = temp; \
@@ -2821,7 +2821,7 @@ extern int making_const_table;
/* Define this if you have special predicates that know special things
about modes. Genrecog will warn about certain forms of
match_operand without a mode; if the operand predicate is listed in
- SPECIAL_MODE_PREDICATES, the warning will be suppressed. */
+ SPECIAL_MODE_PREDICATES, the warning will be suppressed. */
#define SPECIAL_MODE_PREDICATES \
"cc_register", "dominant_cc_register",
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index da3acba8375..974a1b9bcde 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -3623,7 +3623,7 @@
(sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
"TARGET_ARM && arm_arch4"
"*
- /* If the address is invalid, this will split the instruction into two. */
+ /* If the address is invalid, this will split the instruction into two. */
if (bad_signed_byte_operand (operands[1], VOIDmode))
return \"#\";
return \"ldr%?sb\\t%0, %1\";
@@ -3659,7 +3659,7 @@
XEXP (operands[2], 0) = plus_constant (operands[3], low);
operands[1] = plus_constant (XEXP (operands[1], 0), offset - low);
}
- /* Ensure the sum is in correct canonical form */
+ /* Ensure the sum is in correct canonical form. */
else if (GET_CODE (operands[1]) == PLUS
&& GET_CODE (XEXP (operands[1], 1)) != CONST_INT
&& !s_register_operand (XEXP (operands[1], 1), VOIDmode))
@@ -3723,7 +3723,7 @@
(sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
"TARGET_ARM && arm_arch4"
"*
- /* If the address is invalid, this will split the instruction into two. */
+ /* If the address is invalid, this will split the instruction into two. */
if (bad_signed_byte_operand (operands[1], VOIDmode))
return \"#\";
return \"ldr%?sb\\t%0, %1\";
@@ -3775,7 +3775,7 @@
XEXP (operands[2], 0) = plus_constant (operands[0], low);
operands[1] = plus_constant (XEXP (operands[1], 0), offset - low);
}
- /* Ensure the sum is in correct canonical form */
+ /* Ensure the sum is in correct canonical form. */
else if (GET_CODE (operands[1]) == PLUS
&& GET_CODE (XEXP (operands[1], 1)) != CONST_INT
&& !s_register_operand (XEXP (operands[1], 1), VOIDmode))
@@ -4015,7 +4015,7 @@
"
if (TARGET_ARM)
{
- /* Everything except mem = const or mem = mem can be done easily */
+ /* Everything except mem = const or mem = mem can be done easily. */
if (GET_CODE (operands[0]) == MEM)
operands[1] = force_reg (SImode, operands[1]);
if (GET_CODE (operands[1]) == CONST_INT
@@ -4029,7 +4029,7 @@
DONE;
}
}
- else /* TARGET_THUMB.... */
+ else /* TARGET_THUMB.... */
{
if (!no_new_pseudos)
{
@@ -4516,7 +4516,7 @@
}
}
}
- /* Handle loading a large integer during reload */
+ /* Handle loading a large integer during reload. */
else if (GET_CODE (operands[1]) == CONST_INT
&& !const_ok_for_arm (INTVAL (operands[1]))
&& !const_ok_for_arm (~INTVAL (operands[1])))
@@ -4560,7 +4560,7 @@
= replace_equiv_address (operands[1],
copy_to_reg (XEXP (operands[1], 0)));
}
- /* Handle loading a large integer during reload */
+ /* Handle loading a large integer during reload. */
else if (GET_CODE (operands[1]) == CONST_INT
&& !CONST_OK_FOR_THUMB_LETTER (INTVAL (operands[1]), 'I'))
{
@@ -4865,7 +4865,7 @@
= replace_equiv_address (operands[1],
copy_to_reg (XEXP (operands[1], 0)));
}
- /* Handle loading a large integer during reload */
+ /* Handle loading a large integer during reload. */
else if (GET_CODE (operands[1]) == CONST_INT
&& !CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'I'))
{
@@ -5262,7 +5262,7 @@
(use (match_operand:SI 2 "" ""))])]
"TARGET_ARM"
"
- /* Support only fixed point registers */
+ /* Support only fixed point registers. */
if (GET_CODE (operands[2]) != CONST_INT
|| INTVAL (operands[2]) > 14
|| INTVAL (operands[2]) < 2
@@ -8367,7 +8367,7 @@
return \"bics\\t%0, %2, %3, asr #32\;movcs\\t%0, %1\";
}
/* The only case that falls through to here is when both ops 1 & 2
- are constants */
+ are constants. */
}
if (GET_CODE (operands[5]) == GE
@@ -8386,7 +8386,7 @@
return \"ands\\t%0, %2, %3, asr #32\;movcc\\t%0, %1\";
}
/* The only case that falls through to here is when both ops 1 & 2
- are constants */
+ are constants. */
}
if (GET_CODE (operands[4]) == CONST_INT
&& !const_ok_for_arm (INTVAL (operands[4])))
@@ -8523,7 +8523,7 @@
"*
/* If we have an operation where (op x 0) is the identity operation and
the conditional operator is LT or GE and we are comparing against zero and
- everything is in registers then we can do this in two instructions */
+ everything is in registers then we can do this in two instructions. */
if (operands[3] == const0_rtx
&& GET_CODE (operands[7]) != AND
&& GET_CODE (operands[5]) == REG
diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
index 38a9375c856..a77678648d6 100644
--- a/gcc/config/arm/linux-elf.h
+++ b/gcc/config/arm/linux-elf.h
@@ -58,7 +58,7 @@
/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
provides part of the support for getting C++ file-scope static
- object constructed before entering `main'. */
+ object constructed before entering `main'. */
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
diff --git a/gcc/config/arm/vxworks.h b/gcc/config/arm/vxworks.h
index a5a6a09f6e8..afe6b7043be 100644
--- a/gcc/config/arm/vxworks.h
+++ b/gcc/config/arm/vxworks.h
@@ -68,7 +68,7 @@ Boston, MA 02111-1307, USA. */
#define LIB_SPEC ""
/* VxWorks uses object files, not loadable images. make linker just
- combine objects. */
+ combine objects. */
#undef LINK_SPEC
#define LINK_SPEC "-r"
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index a7a71871552..216ec863ba8 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -39,6 +39,7 @@
#include "obstack.h"
#include "function.h"
#include "recog.h"
+#include "ggc.h"
#include "tm_p.h"
#include "target.h"
#include "target-def.h"
@@ -77,18 +78,14 @@ static int default_rtx_costs (rtx, enum rtx_code, enum rtx_code);
static bool avr_rtx_costs (rtx, int, int, int *);
static int avr_address_cost (rtx);
-/* Allocate registers from r25 to r8 for parameters for function calls */
+/* Allocate registers from r25 to r8 for parameters for function calls. */
#define FIRST_CUM_REG 26
/* Temporary register RTX (gen_rtx (REG,QImode,TMP_REGNO)) */
-rtx tmp_reg_rtx;
+static GTY(()) rtx tmp_reg_rtx;
/* Zeroed register RTX (gen_rtx (REG,QImode,ZERO_REGNO)) */
-rtx zero_reg_rtx;
-
-/* RTX for register which will be used for loading immediate values to
- r0-r15 registers. */
-rtx ldi_reg_rtx;
+static GTY(()) rtx zero_reg_rtx;
/* AVR register names {"r0", "r1", ..., "r31"} */
static const char *const avr_regnames[] = REGISTER_NAMES;
@@ -274,31 +271,12 @@ avr_override_options (void)
if (optimize && !TARGET_NO_TABLEJUMP)
avr_case_values_threshold = (!AVR_MEGA || TARGET_CALL_PROLOGUES) ? 8 : 17;
-}
-#if 0 /* Does not play nice with GC. FIXME. */
-/* Initialize TMP_REG_RTX and ZERO_REG_RTX */
-void
-avr_init_once (void)
-{
- tmp_reg_rtx = xcalloc (1, sizeof (struct rtx_def) + 1 * sizeof (rtunion));
- PUT_CODE (tmp_reg_rtx, REG);
- PUT_MODE (tmp_reg_rtx, QImode);
- XINT (tmp_reg_rtx, 0) = TMP_REGNO;
-
- zero_reg_rtx = xcalloc (1, sizeof (struct rtx_def) + 1 * sizeof (rtunion));
- PUT_CODE (zero_reg_rtx, REG);
- PUT_MODE (zero_reg_rtx, QImode);
- XINT (zero_reg_rtx, 0) = ZERO_REGNO;
-
- ldi_reg_rtx = xcalloc (1, sizeof (struct rtx_def) + 1 * sizeof (rtunion));
- PUT_CODE (ldi_reg_rtx, REG);
- PUT_MODE (ldi_reg_rtx, QImode);
- XINT (ldi_reg_rtx, 0) = LDI_REG_REGNO;
+ tmp_reg_rtx = gen_rtx_REG (QImode, TMP_REGNO);
+ zero_reg_rtx = gen_rtx_REG (QImode, ZERO_REGNO);
}
-#endif
-/* return register class from register number */
+/* return register class from register number. */
static const int reg_class_tab[]={
GENERAL_REGS,GENERAL_REGS,GENERAL_REGS,GENERAL_REGS,GENERAL_REGS,
@@ -314,7 +292,7 @@ static const int reg_class_tab[]={
STACK_REG,STACK_REG /* SPL,SPH */
};
-/* Return register class for register R */
+/* Return register class for register R. */
enum reg_class
avr_regno_reg_class (int r)
@@ -437,7 +415,7 @@ avr_regs_to_save (HARD_REG_SET *set)
return count;
}
-/* Compute offset between arg_pointer and frame_pointer */
+/* Compute offset between arg_pointer and frame_pointer. */
int
initial_elimination_offset (int from, int to)
@@ -468,7 +446,7 @@ avr_simple_epilogue (void)
&& ! TREE_THIS_VOLATILE (current_function_decl));
}
-/* This function checks sequence of live registers */
+/* This function checks sequence of live registers. */
static int
sequent_regs_live (void)
@@ -625,7 +603,7 @@ out_set_stack_ptr (FILE *file, int before, int after)
}
-/* Output function prologue */
+/* Output function prologue. */
static void
avr_output_function_prologue (FILE *file, HOST_WIDE_INT size)
@@ -755,7 +733,7 @@ avr_output_function_prologue (FILE *file, HOST_WIDE_INT size)
fprintf (file, "/* prologue end (size=%d) */\n", prologue_size);
}
-/* Output function epilogue */
+/* Output function epilogue. */
static void
avr_output_function_epilogue (FILE *file, HOST_WIDE_INT size)
@@ -1002,7 +980,7 @@ legitimize_address (rtx x, rtx oldx, enum machine_mode mode)
}
-/* Return a pointer register name as a string */
+/* Return a pointer register name as a string. */
static const char *
ptrreg_to_str (int regno)
@@ -1049,7 +1027,7 @@ cond_string (enum rtx_code code)
}
}
-/* Output ADDR to FILE as address */
+/* Output ADDR to FILE as address. */
void
print_operand_address (FILE *file, rtx addr)
@@ -1083,7 +1061,7 @@ print_operand_address (FILE *file, rtx addr)
}
-/* Output X as assembler operand to file FILE */
+/* Output X as assembler operand to file FILE. */
void
print_operand (FILE *file, rtx x, int code)
@@ -1154,7 +1132,7 @@ print_operand (FILE *file, rtx x, int code)
print_operand_address (file, x);
}
-/* Recognize operand OP of mode MODE used in call instructions */
+/* Recognize operand OP of mode MODE used in call instructions. */
int
call_insn_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
@@ -1476,7 +1454,7 @@ avr_num_arg_regs (enum machine_mode mode, tree type)
}
/* Controls whether a function argument is passed
- in a register, and which register. */
+ in a register, and which register. */
rtx
function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
@@ -2614,7 +2592,7 @@ out_movhi_mr_r (rtx insn, rtx op[], int *l)
return "";
}
-/* Return 1 if frame pointer for current function required */
+/* Return 1 if frame pointer for current function required. */
int
frame_pointer_required_p (void)
@@ -2670,7 +2648,7 @@ compare_eq_p (rtx insn)
}
-/* Output test instruction for HImode */
+/* Output test instruction for HImode. */
const char *
out_tsthi (rtx insn, int *l)
@@ -2683,7 +2661,7 @@ out_tsthi (rtx insn, int *l)
if (reg_unused_after (insn, SET_SRC (PATTERN (insn)))
&& compare_eq_p (insn))
{
- /* faster than sbiw if we can clobber the operand */
+ /* Faster than sbiw if we can clobber the operand. */
if (l) *l = 1;
return AS2 (or,%A0,%B0);
}
@@ -2698,7 +2676,7 @@ out_tsthi (rtx insn, int *l)
}
-/* Output test instruction for SImode */
+/* Output test instruction for SImode. */
const char *
out_tstsi (rtx insn, int *l)
@@ -4237,7 +4215,7 @@ adjust_insn_length (rtx insn, int len)
return len;
}
-/* Return nonzero if register REG dead after INSN */
+/* Return nonzero if register REG dead after INSN. */
int
reg_unused_after (rtx insn, rtx reg)
@@ -4368,7 +4346,7 @@ avr_assemble_integer (rtx x, unsigned int size, int aligned_p)
return default_assemble_integer (x, size, aligned_p);
}
-/* Sets section name for declaration DECL */
+/* Sets section name for declaration DECL. */
static void
avr_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED)
@@ -4405,7 +4383,7 @@ avr_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED)
generated assembly code more compact (and thus faster to assemble)
as well as more readable, especially for targets like the i386
(where the only alternative is to output character sequences as
- comma separated lists of numbers). */
+ comma separated lists of numbers). */
void
gas_output_limited_string(FILE *file, const char *str)
@@ -4860,7 +4838,7 @@ avr_rtx_costs (rtx x, int code, int outer_code, int *total)
}
}
-/* Calculate the cost of a memory address */
+/* Calculate the cost of a memory address. */
static int
avr_address_cost (rtx x)
@@ -4925,7 +4903,7 @@ extra_constraint (rtx x, int c)
return 0;
}
-/* Convert condition code CONDITION to the valid AVR condition code */
+/* Convert condition code CONDITION to the valid AVR condition code. */
RTX_CODE
avr_normalize_condition (RTX_CODE condition)
@@ -4970,7 +4948,7 @@ avr_reorg (void)
{
if (GET_CODE (SET_SRC (pattern)) == COMPARE)
{
- /* Now we work under compare insn */
+ /* Now we work under compare insn. */
pattern = SET_SRC (pattern);
if (true_regnum (XEXP (pattern,0)) >= 0
@@ -5389,3 +5367,4 @@ avr_asm_out_dtor (rtx symbol, int priority)
default_dtor_section_asm_out_destructor (symbol, priority);
}
+#include "gt-avr.h"
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index 547e927f52f..0d5cd7c145c 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -20,7 +20,7 @@ along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-/* Names to predefine in the preprocessor for this target machine. */
+/* Names to predefine in the preprocessor for this target machine. */
#define TARGET_CPU_CPP_BUILTINS() \
do \
@@ -41,7 +41,7 @@ Boston, MA 02111-1307, USA. */
} \
while (0)
-/* This declaration should be present. */
+/* This declaration should be present. */
extern int target_flags;
#define MASK_ALL_DEBUG 0x00000FE0
@@ -130,10 +130,10 @@ extern int avr_asm_only_p;
frame pointer. If this macro is defined, GCC will turn on the
`-fomit-frame-pointer' option whenever `-O' is specified. */
-/* Define this if most significant byte of a word is the lowest numbered. */
+/* Define this if most significant byte of a word is the lowest numbered. */
#define BITS_BIG_ENDIAN 0
-/* Define this if most significant byte of a word is the lowest numbered. */
+/* Define this if most significant byte of a word is the lowest numbered. */
#define BYTES_BIG_ENDIAN 0
/* Define this if most significant word of a multiword number is the lowest
@@ -144,7 +144,7 @@ extern int avr_asm_only_p;
/* This is to get correct SI and DI modes in libgcc2.c (32 and 64 bits). */
#define UNITS_PER_WORD 4
#else
-/* Width of a word, in units (bytes). */
+/* Width of a word, in units (bytes). */
#define UNITS_PER_WORD 1
#endif
@@ -157,16 +157,16 @@ extern int avr_asm_only_p;
DImode or Dfmode ... */
#define MAX_FIXED_MODE_SIZE 32
-/* Allocation boundary (in *bits*) for storing arguments in argument list. */
+/* Allocation boundary (in *bits*) for storing arguments in argument list. */
#define PARM_BOUNDARY 8
-/* Allocation boundary (in *bits*) for the code of a function. */
+/* Allocation boundary (in *bits*) for the code of a function. */
#define FUNCTION_BOUNDARY 8
-/* Alignment of field after `int : 0' in a structure. */
+/* Alignment of field after `int : 0' in a structure. */
#define EMPTY_FIELD_BOUNDARY 8
-/* No data type wants to be aligned rounder than this. */
+/* No data type wants to be aligned rounder than this. */
#define BIGGEST_ALIGNMENT 8
@@ -211,7 +211,7 @@ extern int avr_asm_only_p;
#define DOUBLE_TYPE_SIZE 32
/* A C expression for the size in bits of the type `double' on the
target machine. If you don't define this, the default is two
- words. */
+ words. */
#define LONG_DOUBLE_TYPE_SIZE 32
@@ -366,7 +366,7 @@ extern int avr_asm_only_p;
registers must always be saved and the save-multiple-registers
instruction supports only sequences of consecutive registers. On
such machines, define `REG_ALLOC_ORDER' to be an initializer that
- lists the highest numbered allocatable register first. */
+ lists the highest numbered allocatable register first. */
#define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc ()
/* ORDER_REGS_FOR_LOCAL_ALLOC'
@@ -1147,7 +1147,7 @@ typedef struct avr_args {
contains the name of the function, as a string. LIBNAME is 0 when
an ordinary C function call is being processed. Thus, each time
this macro is called, either LIBNAME or FNTYPE is nonzero, but
- never both of them at once. */
+ never both of them at once. */
#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
(function_arg_advance (&CUM, MODE, TYPE, NAMED))
@@ -1160,7 +1160,7 @@ typedef struct avr_args {
This macro need not do anything if the argument in question was
passed on the stack. The compiler knows how to track the amount
- of stack space used for arguments without any special help. */
+ of stack space used for arguments without any special help. */
#define FUNCTION_ARG_REGNO_P(r) function_arg_regno_p(r)
/* A C expression that is nonzero if REGNO is the number of a hard
@@ -2482,11 +2482,4 @@ extern int avr_case_values_threshold;
/* zero register r1 */
#define ZERO_REGNO 1
-/* Temporary register which used for load immediate values to r0-r15 */
-#define LDI_REG_REGNO 31
-
-extern struct rtx_def *tmp_reg_rtx;
-extern struct rtx_def *zero_reg_rtx;
-extern struct rtx_def *ldi_reg_rtx;
-
#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md
index ab7b0ed4783..e253e38a717 100644
--- a/gcc/config/avr/avr.md
+++ b/gcc/config/avr/avr.md
@@ -178,7 +178,7 @@
[(set (match_operand:QI 0 "nonimmediate_operand" "")
(match_operand:QI 1 "general_operand" ""))]
""
- "/* One of the ops has to be in a register */
+ "/* One of the ops has to be in a register. */
if (!register_operand(operand0, QImode)
&& ! (register_operand(operand1, QImode) || const0_rtx == operand1))
operands[1] = copy_to_mode_reg(QImode, operand1);
@@ -226,7 +226,7 @@
""
"
{
- /* One of the ops has to be in a register */
+ /* One of the ops has to be in a register. */
if (!register_operand(operand0, HImode)
&& !(register_operand(operand1, HImode) || const0_rtx == operands[1]))
{
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 0099ff23881..3470f7b8ca1 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -192,7 +192,7 @@ Boston, MA 02111-1307, USA. */
%{!Zdynamiclib:%{A} %{e*} %{m} %{N} %{n} %{r} %{u*} %{x} %{z}} \
%{@:-o %f%u.out}%{!@:%{o*}%{!o:-o a.out}} \
%{!Zdynamiclib:%{!A:%{!nostdlib:%{!nostartfiles:%S}}}} \
- %{L*} %(link_libgcc) %o %{fprofile-arcs:-lgcov} \
+ %{L*} %(link_libgcc) %o %{fprofile-arcs|fprofile-generate:-lgcov} \
%{!nostdlib:%{!nodefaultlibs:%G %L}} \
%{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} \
%{!--help:%{!no-c++filt|c++filt:| c++filt3 }} }}}}}}}}"
diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h
index 063dce655cf..6a138f9f76f 100644
--- a/gcc/config/elfos.h
+++ b/gcc/config/elfos.h
@@ -66,10 +66,6 @@ Boston, MA 02111-1307, USA. */
#define HANDLE_SYSV_PRAGMA 1
-/* System V Release 4 uses DWARF debugging info. */
-
-#define DWARF_DEBUGGING_INFO 1
-
/* All ELF targets can support DWARF-2. */
#define DWARF2_DEBUGGING_INFO 1
diff --git a/gcc/config/h8300/h8300.md b/gcc/config/h8300/h8300.md
index 974330847ec..80683d56876 100644
--- a/gcc/config/h8300/h8300.md
+++ b/gcc/config/h8300/h8300.md
@@ -2090,11 +2090,11 @@
(define_insn "ldm_h8300s_2_normal"
[(parallel
- [(set (reg:SI SP_REG)
- (plus:SI (reg:SI SP_REG) (const_int 8)))
- (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int 4)))
+ [(set (reg:HI SP_REG)
+ (plus:HI (reg:HI SP_REG) (const_int 8)))
+ (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int 4)))
(match_operand:SI 0 "register_operand" ""))
- (set (mem:SI (reg:SI SP_REG))
+ (set (mem:SI (reg:HI SP_REG))
(match_operand:SI 1 "register_operand" ""))])]
"TARGET_H8300S && TARGET_NORMAL_MODE
&& ((REGNO (operands[0]) == 0 && REGNO (operands[1]) == 1)
diff --git a/gcc/config/i386/i386-interix.h b/gcc/config/i386/i386-interix.h
index 9e20b31dbf6..4f21789c99d 100644
--- a/gcc/config/i386/i386-interix.h
+++ b/gcc/config/i386/i386-interix.h
@@ -145,13 +145,13 @@ Boston, MA 02111-1307, USA. */
#define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
do \
{ \
- register const unsigned char *_limited_str = \
+ const unsigned char *_limited_str = \
(const unsigned char *) (STR); \
- register unsigned ch; \
+ unsigned ch; \
fprintf ((FILE), "%s\"", STRING_ASM_OP); \
for (; (ch = *_limited_str); _limited_str++) \
{ \
- register int escape = ESCAPES[ch]; \
+ int escape = ESCAPES[ch]; \
switch (escape) \
{ \
case 0: \
@@ -181,13 +181,13 @@ Boston, MA 02111-1307, USA. */
#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
do \
{ \
- register const unsigned char *_ascii_bytes = \
+ const unsigned char *_ascii_bytes = \
(const unsigned char *) (STR); \
- register const unsigned char *limit = _ascii_bytes + (LENGTH); \
- register unsigned bytes_in_chunk = 0; \
+ const unsigned char *limit = _ascii_bytes + (LENGTH); \
+ unsigned bytes_in_chunk = 0; \
for (; _ascii_bytes < limit; _ascii_bytes++) \
{ \
- register const unsigned char *p; \
+ const unsigned char *p; \
if (bytes_in_chunk >= 64) \
{ \
fputc ('\n', (FILE)); \
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index cb6ffda4b8d..d4653ace834 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3441,7 +3441,7 @@ const_int_1_31_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
reference and a constant. */
int
-symbolic_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+symbolic_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
switch (GET_CODE (op))
{
@@ -3485,7 +3485,7 @@ symbolic_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
/* Return true if the operand contains a @GOT or @GOTOFF reference. */
int
-pic_symbolic_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+pic_symbolic_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
if (GET_CODE (op) != CONST)
return 0;
@@ -3548,7 +3548,7 @@ local_symbolic_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
/* Test for various thread-local symbols. */
int
-tls_symbolic_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+tls_symbolic_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
if (GET_CODE (op) != SYMBOL_REF)
return 0;
@@ -3564,29 +3564,27 @@ tls_symbolic_operand_1 (rtx op, enum tls_model kind)
}
int
-global_dynamic_symbolic_operand (register rtx op,
+global_dynamic_symbolic_operand (rtx op,
enum machine_mode mode ATTRIBUTE_UNUSED)
{
return tls_symbolic_operand_1 (op, TLS_MODEL_GLOBAL_DYNAMIC);
}
int
-local_dynamic_symbolic_operand (register rtx op,
+local_dynamic_symbolic_operand (rtx op,
enum machine_mode mode ATTRIBUTE_UNUSED)
{
return tls_symbolic_operand_1 (op, TLS_MODEL_LOCAL_DYNAMIC);
}
int
-initial_exec_symbolic_operand (register rtx op,
- enum machine_mode mode ATTRIBUTE_UNUSED)
+initial_exec_symbolic_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return tls_symbolic_operand_1 (op, TLS_MODEL_INITIAL_EXEC);
}
int
-local_exec_symbolic_operand (register rtx op,
- enum machine_mode mode ATTRIBUTE_UNUSED)
+local_exec_symbolic_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return tls_symbolic_operand_1 (op, TLS_MODEL_LOCAL_EXEC);
}
@@ -3657,13 +3655,13 @@ constant_call_address_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
/* Match exactly zero and one. */
int
-const0_operand (register rtx op, enum machine_mode mode)
+const0_operand (rtx op, enum machine_mode mode)
{
return op == CONST0_RTX (mode);
}
int
-const1_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+const1_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return op == const1_rtx;
}
@@ -3671,33 +3669,32 @@ const1_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
/* Match 2, 4, or 8. Used for leal multiplicands. */
int
-const248_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+const248_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return (GET_CODE (op) == CONST_INT
&& (INTVAL (op) == 2 || INTVAL (op) == 4 || INTVAL (op) == 8));
}
int
-const_0_to_3_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+const_0_to_3_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return (GET_CODE (op) == CONST_INT && INTVAL (op) >= 0 && INTVAL (op) < 4);
}
int
-const_0_to_7_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+const_0_to_7_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return (GET_CODE (op) == CONST_INT && INTVAL (op) >= 0 && INTVAL (op) < 8);
}
int
-const_0_to_15_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+const_0_to_15_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return (GET_CODE (op) == CONST_INT && INTVAL (op) >= 0 && INTVAL (op) < 16);
}
int
-const_0_to_255_operand (register rtx op,
- enum machine_mode mode ATTRIBUTE_UNUSED)
+const_0_to_255_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return (GET_CODE (op) == CONST_INT && INTVAL (op) >= 0 && INTVAL (op) < 256);
}
@@ -3706,7 +3703,7 @@ const_0_to_255_operand (register rtx op,
/* True if this is a constant appropriate for an increment or decrement. */
int
-incdec_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+incdec_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
/* On Pentium4, the inc and dec operations causes extra dependency on flag
registers, since carry flag is not set. */
@@ -3735,7 +3732,7 @@ shiftdi_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
Which would only happen in pathological cases. */
int
-reg_no_sp_operand (register rtx op, enum machine_mode mode)
+reg_no_sp_operand (rtx op, enum machine_mode mode)
{
rtx t = op;
if (GET_CODE (t) == SUBREG)
@@ -3747,7 +3744,7 @@ reg_no_sp_operand (register rtx op, enum machine_mode mode)
}
int
-mmx_reg_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+mmx_reg_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return MMX_REG_P (op);
}
@@ -3756,7 +3753,7 @@ mmx_reg_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
general_operand. */
int
-general_no_elim_operand (register rtx op, enum machine_mode mode)
+general_no_elim_operand (rtx op, enum machine_mode mode)
{
rtx t = op;
if (GET_CODE (t) == SUBREG)
@@ -3777,7 +3774,7 @@ general_no_elim_operand (register rtx op, enum machine_mode mode)
register_operand or const_int. */
int
-nonmemory_no_elim_operand (register rtx op, enum machine_mode mode)
+nonmemory_no_elim_operand (rtx op, enum machine_mode mode)
{
rtx t = op;
if (GET_CODE (t) == SUBREG)
@@ -3794,7 +3791,7 @@ nonmemory_no_elim_operand (register rtx op, enum machine_mode mode)
otherwise work like register_operand. */
int
-index_register_operand (register rtx op, enum machine_mode mode)
+index_register_operand (rtx op, enum machine_mode mode)
{
rtx t = op;
if (GET_CODE (t) == SUBREG)
@@ -3815,7 +3812,7 @@ index_register_operand (register rtx op, enum machine_mode mode)
/* Return true if op is a Q_REGS class register. */
int
-q_regs_operand (register rtx op, enum machine_mode mode)
+q_regs_operand (rtx op, enum machine_mode mode)
{
if (mode != VOIDmode && GET_MODE (op) != mode)
return 0;
@@ -3827,7 +3824,7 @@ q_regs_operand (register rtx op, enum machine_mode mode)
/* Return true if op is an flags register. */
int
-flags_reg_operand (register rtx op, enum machine_mode mode)
+flags_reg_operand (rtx op, enum machine_mode mode)
{
if (mode != VOIDmode && GET_MODE (op) != mode)
return 0;
@@ -3837,7 +3834,7 @@ flags_reg_operand (register rtx op, enum machine_mode mode)
/* Return true if op is a NON_Q_REGS class register. */
int
-non_q_regs_operand (register rtx op, enum machine_mode mode)
+non_q_regs_operand (rtx op, enum machine_mode mode)
{
if (mode != VOIDmode && GET_MODE (op) != mode)
return 0;
@@ -3885,7 +3882,7 @@ vector_move_operand (rtx op, enum machine_mode mode)
a segment override. */
int
-no_seg_address_operand (register rtx op, enum machine_mode mode)
+no_seg_address_operand (rtx op, enum machine_mode mode)
{
struct ix86_address parts;
@@ -3930,7 +3927,7 @@ sse_comparison_operator (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
}
/* Return 1 if OP is a valid comparison operator in valid mode. */
int
-ix86_comparison_operator (register rtx op, enum machine_mode mode)
+ix86_comparison_operator (rtx op, enum machine_mode mode)
{
enum machine_mode inmode;
enum rtx_code code = GET_CODE (op);
@@ -3971,7 +3968,7 @@ ix86_comparison_operator (register rtx op, enum machine_mode mode)
/* Return 1 if OP is a valid comparison operator testing carry flag
to be set. */
int
-ix86_carry_flag_operator (register rtx op, enum machine_mode mode)
+ix86_carry_flag_operator (rtx op, enum machine_mode mode)
{
enum machine_mode inmode;
enum rtx_code code = GET_CODE (op);
@@ -4003,7 +4000,7 @@ ix86_carry_flag_operator (register rtx op, enum machine_mode mode)
/* Return 1 if OP is a comparison operator that can be issued by fcmov. */
int
-fcmov_comparison_operator (register rtx op, enum machine_mode mode)
+fcmov_comparison_operator (rtx op, enum machine_mode mode)
{
enum machine_mode inmode;
enum rtx_code code = GET_CODE (op);
@@ -4040,8 +4037,7 @@ fcmov_comparison_operator (register rtx op, enum machine_mode mode)
/* Return 1 if OP is a binary operator that can be promoted to wider mode. */
int
-promotable_binary_operator (register rtx op,
- enum machine_mode mode ATTRIBUTE_UNUSED)
+promotable_binary_operator (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
switch (GET_CODE (op))
{
@@ -4065,7 +4061,7 @@ promotable_binary_operator (register rtx op,
into registers. */
int
-cmp_fp_expander_operand (register rtx op, enum machine_mode mode)
+cmp_fp_expander_operand (rtx op, enum machine_mode mode)
{
if (mode != VOIDmode && mode != GET_MODE (op))
return 0;
@@ -4077,7 +4073,7 @@ cmp_fp_expander_operand (register rtx op, enum machine_mode mode)
/* Match an SI or HImode register for a zero_extract. */
int
-ext_register_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+ext_register_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
int regno;
if ((!TARGET_64BIT || GET_MODE (op) != DImode)
@@ -4096,7 +4092,7 @@ ext_register_operand (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
OP is the expression matched, and MODE is its mode. */
int
-binary_fp_operator (register rtx op, enum machine_mode mode)
+binary_fp_operator (rtx op, enum machine_mode mode)
{
if (mode != VOIDmode && mode != GET_MODE (op))
return 0;
@@ -4115,13 +4111,13 @@ binary_fp_operator (register rtx op, enum machine_mode mode)
}
int
-mult_operator (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+mult_operator (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return GET_CODE (op) == MULT;
}
int
-div_operator (register rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
+div_operator (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
return GET_CODE (op) == DIV;
}
@@ -4137,7 +4133,7 @@ arith_or_logical_operator (rtx op, enum machine_mode mode)
/* Returns 1 if OP is memory operand with a displacement. */
int
-memory_displacement_operand (register rtx op, enum machine_mode mode)
+memory_displacement_operand (rtx op, enum machine_mode mode)
{
struct ix86_address parts;
@@ -4179,7 +4175,7 @@ cmpsi_operand (rtx op, enum machine_mode mode)
modRM array. */
int
-long_memory_operand (register rtx op, enum machine_mode mode)
+long_memory_operand (rtx op, enum machine_mode mode)
{
if (! memory_operand (op, mode))
return 0;
@@ -4375,8 +4371,8 @@ standard_sse_constant_p (rtx x)
int
symbolic_reference_mentioned_p (rtx op)
{
- register const char *fmt;
- register int i;
+ const char *fmt;
+ int i;
if (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == LABEL_REF)
return 1;
@@ -4386,7 +4382,7 @@ symbolic_reference_mentioned_p (rtx op)
{
if (fmt[i] == 'E')
{
- register int j;
+ int j;
for (j = XVECLEN (op, i) - 1; j >= 0; j--)
if (symbolic_reference_mentioned_p (XVECEXP (op, i, j)))
@@ -5052,7 +5048,7 @@ ix86_compute_frame_layout (struct ix86_frame *frame)
static void
ix86_emit_save_regs (void)
{
- register int regno;
+ int regno;
rtx insn;
for (regno = FIRST_PSEUDO_REGISTER - 1; regno >= 0; regno--)
@@ -5429,7 +5425,7 @@ ix86_output_function_epilogue (FILE *file ATTRIBUTE_UNUSED,
strictly valid, but still used for computing length of lea instruction. */
static int
-ix86_decompose_address (register rtx addr, struct ix86_address *out)
+ix86_decompose_address (rtx addr, struct ix86_address *out)
{
rtx base = NULL_RTX;
rtx index = NULL_RTX;
@@ -5791,7 +5787,7 @@ legitimate_pic_operand_p (rtx x)
in PIC mode. */
int
-legitimate_pic_address_disp_p (register rtx disp)
+legitimate_pic_address_disp_p (rtx disp)
{
bool saw_plus;
@@ -5905,7 +5901,7 @@ legitimate_pic_address_disp_p (register rtx disp)
be recognized. */
int
-legitimate_address_p (enum machine_mode mode, register rtx addr, int strict)
+legitimate_address_p (enum machine_mode mode, rtx addr, int strict)
{
struct ix86_address parts;
rtx base, index, disp;
@@ -6473,8 +6469,7 @@ legitimize_tls_address (rtx x, enum tls_model model, int for_mov)
See comments by legitimize_pic_address in i386.c for details. */
rtx
-legitimize_address (register rtx x, register rtx oldx ATTRIBUTE_UNUSED,
- enum machine_mode mode)
+legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, enum machine_mode mode)
{
int changed = 0;
unsigned log;
@@ -6614,8 +6609,8 @@ legitimize_address (register rtx x, register rtx oldx ATTRIBUTE_UNUSED,
if (GET_CODE (XEXP (x, 0)) == REG)
{
- register rtx temp = gen_reg_rtx (Pmode);
- register rtx val = force_operand (XEXP (x, 1), temp);
+ rtx temp = gen_reg_rtx (Pmode);
+ rtx val = force_operand (XEXP (x, 1), temp);
if (val != temp)
emit_move_insn (temp, val);
@@ -6625,8 +6620,8 @@ legitimize_address (register rtx x, register rtx oldx ATTRIBUTE_UNUSED,
else if (GET_CODE (XEXP (x, 1)) == REG)
{
- register rtx temp = gen_reg_rtx (Pmode);
- register rtx val = force_operand (XEXP (x, 0), temp);
+ rtx temp = gen_reg_rtx (Pmode);
+ rtx val = force_operand (XEXP (x, 0), temp);
if (val != temp)
emit_move_insn (temp, val);
@@ -7508,7 +7503,7 @@ print_operand (FILE *file, rtx x, int code)
/* Print a memory operand whose address is ADDR. */
void
-print_operand_address (FILE *file, register rtx addr)
+print_operand_address (FILE *file, rtx addr)
{
struct ix86_address parts;
rtx base, index, disp;
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 35666627719..08424a4caac 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -1581,7 +1581,9 @@ enum reg_class
|| ((CLASS) == BREG) \
|| ((CLASS) == AD_REGS) \
|| ((CLASS) == SIREG) \
- || ((CLASS) == DIREG))
+ || ((CLASS) == DIREG) \
+ || ((CLASS) == FP_TOP_REG) \
+ || ((CLASS) == FP_SECOND_REG))
/* Return a class of registers that cannot change FROM mode to TO mode.
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 0eff393bf5f..8b32c5e014c 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -17168,33 +17168,61 @@
[(match_operand:SI 0 "register_operand" "")]
"TARGET_STACK_PROBE"
{
- if (TARGET_64BIT)
- emit_insn (gen_allocate_stack_worker_rex64 (operands[0]));
+ if (reload_completed)
+ {
+ if (TARGET_64BIT)
+ emit_insn (gen_allocate_stack_worker_rex64_postreload (operands[0]));
+ else
+ emit_insn (gen_allocate_stack_worker_postreload (operands[0]));
+ }
else
- emit_insn (gen_allocate_stack_worker_1 (operands[0]));
+ {
+ if (TARGET_64BIT)
+ emit_insn (gen_allocate_stack_worker_rex64 (operands[0]));
+ else
+ emit_insn (gen_allocate_stack_worker_1 (operands[0]));
+ }
DONE;
})
(define_insn "allocate_stack_worker_1"
[(unspec:SI [(match_operand:SI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
(set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
- (clobber (match_dup 0))
+ (clobber (match_scratch:SI 1 "=0"))
(clobber (reg:CC 17))]
"!TARGET_64BIT && TARGET_STACK_PROBE"
"call\t__alloca"
[(set_attr "type" "multi")
(set_attr "length" "5")])
+(define_expand "allocate_stack_worker_postreload"
+ [(parallel [(unspec:SI [(match_operand:SI 0 "register_operand" "a")]
+ UNSPEC_STACK_PROBE)
+ (set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
+ (clobber (match_dup 0))
+ (clobber (reg:CC 17))])]
+ ""
+ "")
+
(define_insn "allocate_stack_worker_rex64"
[(unspec:DI [(match_operand:DI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
(set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0)))
- (clobber (match_dup 0))
+ (clobber (match_scratch:DI 1 "=0"))
(clobber (reg:CC 17))]
"TARGET_64BIT && TARGET_STACK_PROBE"
"call\t__alloca"
[(set_attr "type" "multi")
(set_attr "length" "5")])
+(define_expand "allocate_stack_worker_rex64_postreload"
+ [(parallel [(unspec:DI [(match_operand:DI 0 "register_operand" "a")]
+ UNSPEC_STACK_PROBE)
+ (set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0)))
+ (clobber (match_dup 0))
+ (clobber (reg:CC 17))])]
+ ""
+ "")
+
(define_expand "allocate_stack"
[(parallel [(set (match_operand:SI 0 "register_operand" "=r")
(minus:SI (reg:SI 7)
diff --git a/gcc/config/i386/i386elf.h b/gcc/config/i386/i386elf.h
index b484126b6af..ed6b41aa9b3 100644
--- a/gcc/config/i386/i386elf.h
+++ b/gcc/config/i386/i386elf.h
@@ -65,13 +65,13 @@ Boston, MA 02111-1307, USA. */
#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
do \
{ \
- register const unsigned char *_ascii_bytes = \
+ const unsigned char *_ascii_bytes = \
(const unsigned char *) (STR); \
- register const unsigned char *limit = _ascii_bytes + (LENGTH); \
- register unsigned bytes_in_chunk = 0; \
+ const unsigned char *limit = _ascii_bytes + (LENGTH); \
+ unsigned bytes_in_chunk = 0; \
for (; _ascii_bytes < limit; _ascii_bytes++) \
{ \
- register const unsigned char *p; \
+ const unsigned char *p; \
if (bytes_in_chunk >= 64) \
{ \
fputc ('\n', (FILE)); \
diff --git a/gcc/config/i386/ptx4-i.h b/gcc/config/i386/ptx4-i.h
index 65beba0711a..5fcd074f48b 100644
--- a/gcc/config/i386/ptx4-i.h
+++ b/gcc/config/i386/ptx4-i.h
@@ -57,13 +57,13 @@ Boston, MA 02111-1307, USA. */
#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
do \
{ \
- register const unsigned char *_ascii_bytes = \
+ const unsigned char *_ascii_bytes = \
(const unsigned char *) (STR); \
- register const unsigned char *limit = _ascii_bytes + (LENGTH); \
- register unsigned bytes_in_chunk = 0; \
+ const unsigned char *limit = _ascii_bytes + (LENGTH); \
+ unsigned bytes_in_chunk = 0; \
for (; _ascii_bytes < limit; _ascii_bytes++) \
{ \
- register const unsigned char *p; \
+ const unsigned char *p; \
if (bytes_in_chunk >= 64) \
{ \
fputc ('\n', (FILE)); \
diff --git a/gcc/config/i386/sco5.h b/gcc/config/i386/sco5.h
index 455741d610b..bb872d5ec15 100644
--- a/gcc/config/i386/sco5.h
+++ b/gcc/config/i386/sco5.h
@@ -60,7 +60,6 @@ Boston, MA 02111-1307, USA. */
#define DBX_REGISTER_NUMBER(n) svr4_dbx_register_map[n]
#define DWARF2_DEBUGGING_INFO 1
-#define DWARF_DEBUGGING_INFO 1
#define DBX_DEBUGGING_INFO 1
#undef PREFERRED_DEBUGGING_TYPE
diff --git a/gcc/config/i386/sysv4.h b/gcc/config/i386/sysv4.h
index 18eadf52592..244700637ec 100644
--- a/gcc/config/i386/sysv4.h
+++ b/gcc/config/i386/sysv4.h
@@ -52,13 +52,13 @@ Boston, MA 02111-1307, USA. */
#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
do \
{ \
- register const unsigned char *_ascii_bytes = \
+ const unsigned char *_ascii_bytes = \
(const unsigned char *) (STR); \
- register const unsigned char *limit = _ascii_bytes + (LENGTH); \
- register unsigned bytes_in_chunk = 0; \
+ const unsigned char *limit = _ascii_bytes + (LENGTH); \
+ unsigned bytes_in_chunk = 0; \
for (; _ascii_bytes < limit; _ascii_bytes++) \
{ \
- register const unsigned char *p; \
+ const unsigned char *p; \
if (bytes_in_chunk >= 64) \
{ \
fputc ('\n', (FILE)); \
diff --git a/gcc/config/i386/x86-64.h b/gcc/config/i386/x86-64.h
index e49086a2328..16b06331b98 100644
--- a/gcc/config/i386/x86-64.h
+++ b/gcc/config/i386/x86-64.h
@@ -68,7 +68,6 @@ Boston, MA 02111-1307, USA. */
/* i386 System V Release 4 uses DWARF debugging info.
x86-64 ABI specifies DWARF2. */
-#undef DWARF_DEBUGGING_INFO
#define DWARF2_DEBUGGING_INFO 1
#define DWARF2_UNWIND_INFO 1
/* Incorrectly autodetected in cross compilation. */
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index beba14fe429..67df9cb2b90 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -3742,8 +3742,12 @@ ia64_va_arg (tree valist, tree type)
/* Variable sized types are passed by reference. */
if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
{
- rtx addr = std_expand_builtin_va_arg (valist, build_pointer_type (type));
- return gen_rtx_MEM (ptr_mode, force_reg (Pmode, addr));
+ rtx addr = force_reg (ptr_mode,
+ std_expand_builtin_va_arg (valist, build_pointer_type (type)));
+#ifdef POINTERS_EXTEND_UNSIGNED
+ addr = convert_memory_address (Pmode, addr);
+#endif
+ return gen_rtx_MEM (ptr_mode, addr);
}
/* Arguments with alignment larger than 8 bytes start at the next even
@@ -7511,6 +7515,10 @@ ia64_in_small_data_p (tree exp)
if (TREE_CODE (exp) == STRING_CST)
return false;
+ /* Functions are never small data. */
+ if (TREE_CODE (exp) == FUNCTION_DECL)
+ return false;
+
if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp))
{
const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (exp));
diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h
index 63ff8e8fab2..1ed1f095df0 100644
--- a/gcc/config/m32r/m32r.h
+++ b/gcc/config/m32r/m32r.h
@@ -1721,7 +1721,6 @@ extern char m32r_punct_chars[256];
/* Generate DBX and DWARF debugging information. */
#define DBX_DEBUGGING_INFO 1
-#define DWARF_DEBUGGING_INFO 1
#define DWARF2_DEBUGGING_INFO 1
/* Prefer STABS (for now). */
diff --git a/gcc/config/m32r/m32r.md b/gcc/config/m32r/m32r.md
index 709c194fb46..4c9bb6f1276 100644
--- a/gcc/config/m32r/m32r.md
+++ b/gcc/config/m32r/m32r.md
@@ -500,7 +500,7 @@
(define_split
[(set (match_operand:SI 0 "register_operand" "")
- (match_operand:SI 1 "seth_add3_operand" "i"))]
+ (match_operand:SI 1 "seth_add3_operand" ""))]
"TARGET_ADDR32"
[(set (match_dup 0)
(high:SI (match_dup 1)))
diff --git a/gcc/config/m68k/uclinux.h b/gcc/config/m68k/uclinux.h
index 596cc1979c8..3ef0b9742a1 100644
--- a/gcc/config/m68k/uclinux.h
+++ b/gcc/config/m68k/uclinux.h
@@ -30,7 +30,7 @@ Boston, MA 02111-1307, USA. */
profiling, or libg.a. */
#undef LIB_SPEC
#define LIB_SPEC "\
-%{mid-shared-library:-R libc.gdb%s} -lc \
+%{mid-shared-library:-R libc.gdb%s -elf2flt -shared-lib-id 0} -lc \
"
/* we don't want a .eh_frame section. */
diff --git a/gcc/config/mcore/mcore-elf.h b/gcc/config/mcore/mcore-elf.h
index c879368d4a7..deb44d66be0 100644
--- a/gcc/config/mcore/mcore-elf.h
+++ b/gcc/config/mcore/mcore-elf.h
@@ -31,9 +31,6 @@ Boston, MA 02111-1307, USA. */
#undef PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
-/* But allow DWARF 1 if the user wants it. */
-#define DWARF_DEBUGGING_INFO 1
-
#define EXPORTS_SECTION_ASM_OP "\t.section .exports"
#define SUBTARGET_EXTRA_SECTIONS in_exports
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index c748bac73af..ba358fcfbf6 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -4663,10 +4663,10 @@ override_options (void)
/* Adapt wording to IRIX version: IRIX 5 only had a single ABI,
so -mabi=32 isn't usually specified. */
if (TARGET_IRIX5)
- warning ("-g is only supported using GNU as,");
+ inform ("-g is only supported using GNU as,");
else
- warning ("-g is only supported using GNU as with -mabi=32,");
- warning ("-g option disabled");
+ inform ("-g is only supported using GNU as with -mabi=32,");
+ inform ("-g option disabled");
write_symbols = NO_DEBUG;
}
}
diff --git a/gcc/config/mips/t-iris6 b/gcc/config/mips/t-iris6
index 05f364bc89f..e6713106dba 100644
--- a/gcc/config/mips/t-iris6
+++ b/gcc/config/mips/t-iris6
@@ -12,11 +12,7 @@ INSTALL_LIBGCC = install-multilib
# end labels to the .ctors and .dtors section when we link using gcc.
EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o
-# When the native assembler is in use, -g is not supported with the O32 ABI
-# and we get a warning for every -mabi=32 compilation. Work around this
-# by adding -Wno-error.
-CRTSTUFF_T_CFLAGS=-g1 -Wno-error
-TARGET_LIBGCC2_CFLAGS = -Wno-error
+CRTSTUFF_T_CFLAGS=-g1
LIB2FUNCS_EXTRA = $(srcdir)/config/mips/_tilib.c
diff --git a/gcc/config/netware.h b/gcc/config/netware.h
index 64278835f3d..241e92dcf7c 100644
--- a/gcc/config/netware.h
+++ b/gcc/config/netware.h
@@ -51,7 +51,6 @@ Boston, MA 02111-1307, USA. */
/* set debugging info */
#define DBX_DEBUGGING_INFO 1
#undef SDB_DEBUGGING_INFO
-#undef DWARF_DEBUGGING_INFO
#undef XCOFF_DEBUGGING_INFO
#undef PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
diff --git a/gcc/config/ns32k/ns32k.c b/gcc/config/ns32k/ns32k.c
index 3573b711242..e80724ecf40 100644
--- a/gcc/config/ns32k/ns32k.c
+++ b/gcc/config/ns32k/ns32k.c
@@ -150,9 +150,7 @@ struct gcc_target targetm = TARGET_INITIALIZER;
#endif
static void
-ns32k_output_function_prologue (file, size)
- FILE *file;
- HOST_WIDE_INT size;
+ns32k_output_function_prologue (FILE *file, HOST_WIDE_INT size)
{
register int regno, g_regs_used = 0;
int used_regs_buf[8], *bufp = used_regs_buf;
@@ -330,9 +328,7 @@ ns32k_output_function_prologue (file, size)
#if !defined (MERLIN_TARGET) && !defined (UTEK_ASM)
static void
-ns32k_output_function_epilogue (file, size)
- FILE *file;
- HOST_WIDE_INT size;
+ns32k_output_function_epilogue (FILE *file, HOST_WIDE_INT size)
{
register int regno, g_regs_used = 0, f_regs_used = 0;
int used_regs_buf[8], *bufp = used_regs_buf;
@@ -472,9 +468,7 @@ ns32k_output_function_epilogue (file, size)
/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
int
-hard_regno_mode_ok (regno, mode)
- int regno;
- enum machine_mode mode;
+hard_regno_mode_ok (int regno, enum machine_mode mode)
{
int size = GET_MODE_UNIT_SIZE (mode);
@@ -498,10 +492,7 @@ hard_regno_mode_ok (regno, mode)
}
static bool
-ns32k_rtx_costs (x, code, outer_code, total)
- rtx x;
- int code, outer_code ATTRIBUTE_UNUSED;
- int *total;
+ns32k_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total)
{
switch (code)
{
@@ -529,9 +520,8 @@ ns32k_rtx_costs (x, code, outer_code, total)
}
}
-int register_move_cost (CLASS1, CLASS2)
- enum reg_class CLASS1;
- enum reg_class CLASS2;
+int
+register_move_cost (enum reg_class CLASS1, enum reg_class CLASS2)
{
if (CLASS1 == NO_REGS || CLASS2 == NO_REGS)
return 2;
@@ -550,10 +540,10 @@ int register_move_cost (CLASS1, CLASS2)
#if 0
/* We made the insn definitions copy from floating point to general
registers via the stack. */
-int secondary_memory_needed (CLASS1, CLASS2, M)
- enum reg_class CLASS1;
- enum reg_class CLASS2;
- enum machine_mode M;
+int
+secondary_memory_needed (enum reg_class CLASS1,
+ enum reg_class CLASS2,
+ enum machine_mode M)
{
int ret = ((SUBSET_P (CLASS1, FP_REGS) && !SUBSET_P (CLASS2, FP_REGS))
|| (!SUBSET_P (CLASS1, FP_REGS) && SUBSET_P (CLASS2, FP_REGS)));
@@ -567,8 +557,7 @@ int secondary_memory_needed (CLASS1, CLASS2, M)
the default. */
static int
-ns32k_address_cost (operand)
- rtx operand;
+ns32k_address_cost (rtx operand)
{
int cost = 0;
@@ -623,10 +612,9 @@ ns32k_address_cost (operand)
NO_REGS is returned. */
enum reg_class
-secondary_reload_class (class, mode, in)
- enum reg_class class;
- enum machine_mode mode ATTRIBUTE_UNUSED;
- rtx in;
+secondary_reload_class (enum reg_class class,
+ enum machine_mode mode ATTRIBUTE_UNUSED,
+ rtx in)
{
int regno = true_regnum (in);
@@ -646,8 +634,7 @@ secondary_reload_class (class, mode, in)
multiplier (for MULT). */
static rtx
-gen_indexed_expr (base, index, scale)
- rtx base, index, scale;
+gen_indexed_expr (rtx base, rtx index, rtx scale)
{
rtx addr;
@@ -669,10 +656,7 @@ gen_indexed_expr (base, index, scale)
that parallel "operands". */
void
-split_di (operands, num, lo_half, hi_half)
- rtx operands[];
- int num;
- rtx lo_half[], hi_half[];
+split_di (rtx operands[], int num, rtx lo_half[], rtx hi_half[])
{
while (num--)
{
@@ -699,8 +683,7 @@ split_di (operands, num, lo_half, hi_half)
for moving operands[1] into operands[0] as a fullword. */
static const char *
-singlemove_string (operands)
- rtx *operands;
+singlemove_string (rtx *operands)
{
if (GET_CODE (operands[1]) == CONST_INT
&& INTVAL (operands[1]) <= 7
@@ -710,8 +693,7 @@ singlemove_string (operands)
}
const char *
-output_move_double (operands)
- rtx *operands;
+output_move_double (rtx *operands)
{
enum anon1 { REGOP, OFFSOP, PUSHOP, CNSTOP, RNDOP } optype0, optype1;
rtx latehalf[2];
@@ -849,10 +831,7 @@ output_move_double (operands)
operands[3] is the alignment. */
static void
-move_tail (operands, bytes, offset)
- rtx operands[];
- int bytes;
- int offset;
+move_tail (rtx operands[], int bytes, int offset)
{
if (bytes & 2)
{
@@ -866,8 +845,7 @@ move_tail (operands, bytes, offset)
}
void
-expand_block_move (operands)
- rtx operands[];
+expand_block_move (rtx operands[])
{
rtx bytes_rtx = operands[2];
rtx align_rtx = operands[3];
@@ -994,9 +972,7 @@ expand_block_move (operands)
/* Returns 1 if OP contains a global symbol reference */
int
-global_symbolic_reference_mentioned_p (op, f)
- rtx op;
- int f;
+global_symbolic_reference_mentioned_p (rtx op, int f)
{
register const char *fmt;
register int i;
@@ -1034,8 +1010,7 @@ global_symbolic_reference_mentioned_p (op, f)
/* Returns 1 if OP contains a symbol reference */
int
-symbolic_reference_mentioned_p (op)
- rtx op;
+symbolic_reference_mentioned_p (rtx op)
{
register const char *fmt;
register int i;
@@ -1077,12 +1052,10 @@ const struct attribute_spec ns32k_attribute_table[] =
/* Handle an attribute requiring a FUNCTION_TYPE, FIELD_DECL or TYPE_DECL;
arguments as in struct attribute_spec.handler. */
static tree
-ns32k_handle_fntype_attribute (node, name, args, flags, no_add_attrs)
- tree *node;
- tree name;
- tree args ATTRIBUTE_UNUSED;
- int flags ATTRIBUTE_UNUSED;
- bool *no_add_attrs;
+ns32k_handle_fntype_attribute (tree *node, tree name,
+ tree args ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED,
+ bool *no_add_attrs)
{
if (TREE_CODE (*node) != FUNCTION_TYPE
&& TREE_CODE (*node) != FIELD_DECL
@@ -1115,10 +1088,7 @@ ns32k_handle_fntype_attribute (node, name, args, flags, no_add_attrs)
The attribute stdcall is equivalent to RET on a per module basis. */
int
-ns32k_return_pops_args (fundecl, funtype, size)
- tree fundecl ATTRIBUTE_UNUSED;
- tree funtype;
- int size;
+ns32k_return_pops_args (tree fundecl ATTRIBUTE_UNUSED, tree funtype, int size)
{
int rtd = TARGET_RTD;
@@ -1149,10 +1119,7 @@ ns32k_return_pops_args (fundecl, funtype, size)
/* XXX time 12% of cpu time is in fprintf for non optimizing */
void
-print_operand (file, x, code)
- FILE *file;
- rtx x;
- int code;
+print_operand (FILE *file, rtx x, int code)
{
if (code == '$')
PUT_IMMEDIATE_PREFIX (file);
@@ -1240,9 +1207,7 @@ print_operand (file, x, code)
90-11-25 Tatu Yl|nen <ylo@cs.hut.fi> */
void
-print_operand_address (file, addr)
- register FILE *file;
- register rtx addr;
+print_operand_address (register FILE *file, register rtx addr)
{
static const char scales[] = { 'b', 'w', 'd', 0, 'q', };
rtx offset, base, indexexp, tmp;
@@ -1524,8 +1489,7 @@ print_operand_address (file, addr)
better performance in many common cases by using other
techniques. */
const char *
-output_shift_insn (operands)
- rtx *operands;
+output_shift_insn (rtx *operands)
{
if (GET_CODE (operands[2]) == CONST_INT
&& INTVAL (operands[2]) > 0
@@ -1574,9 +1538,7 @@ output_shift_insn (operands)
}
const char *
-output_move_dconst (n, s)
- int n;
- const char *s;
+output_move_dconst (int n, const char *s)
{
static char r[32];
diff --git a/gcc/config/ptx4.h b/gcc/config/ptx4.h
index c29d8d30fee..33e91d15135 100644
--- a/gcc/config/ptx4.h
+++ b/gcc/config/ptx4.h
@@ -33,7 +33,6 @@ Boston, MA 02111-1307, USA.
#undef PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
-#undef DWARF_DEBUGGING_INFO
#define DWARF2_DEBUGGING_INFO 1
/* Cpp, assembler, linker, library, and startfile spec's. */
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 414aee13593..53c8b36a86d 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -2448,7 +2448,7 @@ legitimate_offset_address_p (enum machine_mode mode, rtx x, int strict)
case DFmode:
case DImode:
- if (!TARGET_POWERPC64)
+ if (mode == DFmode || !TARGET_POWERPC64)
extra = 4;
else if (offset & 3)
return false;
@@ -2456,7 +2456,7 @@ legitimate_offset_address_p (enum machine_mode mode, rtx x, int strict)
case TFmode:
case TImode:
- if (!TARGET_POWERPC64)
+ if (mode == TFmode || !TARGET_POWERPC64)
extra = 12;
else if (offset & 3)
return false;
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 402c08cfac3..3ab0465a316 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -8159,16 +8159,18 @@
[(set_attr "type" "*,load,store,*,*,*")
(set_attr "length" "8,8,8,8,12,16")])
+; ld/std require word-aligned displacements, so use offsettable constraint.
+; List o->r and r->o before r->r for reload.
(define_insn "*movdf_hardfloat64"
- [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!cl,!r,!r,!r,!r")
- (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,r,h,G,H,F"))]
+ [(set (match_operand:DF 0 "nonimmediate_operand" "=o,??r,!r,f,f,m,!cl,!r,!r,!r,!r")
+ (match_operand:DF 1 "input_operand" "r,o,r,f,m,f,r,h,G,H,F"))]
"TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
&& (gpc_reg_operand (operands[0], DFmode)
|| gpc_reg_operand (operands[1], DFmode))"
"@
- mr %0,%1
- ld%U1%X1 %0,%1
std%U0%X0 %1,%0
+ ld%U1%X1 %0,%1
+ mr %0,%1
fmr %0,%1
lfd%U1%X1 %0,%1
stfd%U0%X0 %1,%0
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index fb9f5a73709..2969880edad 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -265,10 +265,6 @@ Boston, MA 02111-1307, USA. */
#undef DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
-/* System V Release 4 uses DWARF debugging info. Buf DWARF1 doesn't do
- 64-bit anything, so we use DWARF2. */
-
-#undef DWARF_DEBUGGING_INFO
#define DWARF2_DEBUGGING_INFO 1
#define DBX_DEBUGGING_INFO 1
diff --git a/gcc/config/sparc/liteelf.h b/gcc/config/sparc/liteelf.h
index b33690727b3..49a2089b211 100644
--- a/gcc/config/sparc/liteelf.h
+++ b/gcc/config/sparc/liteelf.h
@@ -29,7 +29,6 @@ Boston, MA 02111-1307, USA. */
/* Default to dwarf2 in ELF. */
-#define DWARF_DEBUGGING_INFO 1
#define DWARF2_DEBUGGING_INFO 1
#undef PREFERRED_DEBUGGING_TYPE
diff --git a/gcc/config/sparc/sol26-sld.h b/gcc/config/sparc/sol26-sld.h
index 74b54335011..2e7fed9424c 100644
--- a/gcc/config/sparc/sol26-sld.h
+++ b/gcc/config/sparc/sol26-sld.h
@@ -1,6 +1,5 @@
-/* Up through Solaris 2.6, the system linker does not work with DWARF
- or DWARF2, since it does not have working support for relocations
- to unaligned data. */
+/* Up through Solaris 2.6, the system linker does not work with DWARF2
+ since it does not have working support for relocations to unaligned
+ data. */
-#undef DWARF_DEBUGGING_INFO
#undef DWARF2_DEBUGGING_INFO
diff --git a/gcc/config/sparc/sp86x-elf.h b/gcc/config/sparc/sp86x-elf.h
index 04ed624cf72..593400d0dd2 100644
--- a/gcc/config/sparc/sp86x-elf.h
+++ b/gcc/config/sparc/sp86x-elf.h
@@ -29,7 +29,6 @@ Boston, MA 02111-1307, USA. */
/* Default to dwarf2 in ELF. */
-#define DWARF_DEBUGGING_INFO 1
#define DWARF2_DEBUGGING_INFO 1
#undef PREFERRED_DEBUGGING_TYPE
diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h
index 339acecc20c..085eb8ce648 100644
--- a/gcc/config/vxworks.h
+++ b/gcc/config/vxworks.h
@@ -62,4 +62,3 @@ Boston, MA 02111-1307, USA. */
/* Only supported debug format is Dwarf2. */
#undef DBX_DEBUGGING_INFO
-#undef DWARF_DEBUGGING_INFO
diff --git a/gcc/config/xtensa/elf.h b/gcc/config/xtensa/elf.h
index 849be87edb0..1ef309bfa8c 100644
--- a/gcc/config/xtensa/elf.h
+++ b/gcc/config/xtensa/elf.h
@@ -21,7 +21,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#define TARGET_SECTION_TYPE_FLAGS xtensa_multibss_section_type_flags
-/* Don't assume anything about the header files. */
+/* Don't assume anything about the header files. */
#define NO_IMPLICIT_EXTERN_C
#undef ASM_APP_ON
diff --git a/gcc/config/xtensa/xtensa-protos.h b/gcc/config/xtensa/xtensa-protos.h
index 0d6d45f1640..cf7f09075c9 100644
--- a/gcc/config/xtensa/xtensa-protos.h
+++ b/gcc/config/xtensa/xtensa-protos.h
@@ -22,7 +22,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifndef __XTENSA_PROTOS_H__
#define __XTENSA_PROTOS_H__
-/* Functions to test whether an immediate fits in a given field. */
+/* Functions to test whether an immediate fits in a given field. */
extern int xtensa_simm7 (int);
extern int xtensa_simm8 (int);
extern int xtensa_simm8x256 (int);
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 74e4b3051e3..e8926c9c1e3 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -600,7 +600,7 @@ move_operand (rtx op, enum machine_mode mode)
case SImode:
if (TARGET_CONST16)
return CONSTANT_P (op);
- /* fall through */
+ /* Fall through. */
case HImode:
case QImode:
@@ -652,12 +652,12 @@ constantpool_address_p (rtx addr)
{
rtx offset;
- /* only handle (PLUS (SYM, OFFSET)) form */
+ /* Only handle (PLUS (SYM, OFFSET)) form. */
addr = XEXP (addr, 0);
if (GET_CODE (addr) != PLUS)
return FALSE;
- /* make sure the address is word aligned */
+ /* Make sure the address is word aligned. */
offset = XEXP (addr, 1);
if ((GET_CODE (offset) != CONST_INT)
|| ((INTVAL (offset) & 3) != 0))
@@ -728,7 +728,7 @@ xtensa_extend_reg (rtx dst, rtx src)
rtx temp = gen_reg_rtx (SImode);
rtx shift = GEN_INT (BITS_PER_WORD - GET_MODE_BITSIZE (GET_MODE (src)));
- /* generate paradoxical subregs as needed so that the modes match */
+ /* Generate paradoxical subregs as needed so that the modes match. */
src = simplify_gen_subreg (SImode, src, GET_MODE (src), 0);
dst = simplify_gen_subreg (SImode, dst, GET_MODE (dst), 0);
@@ -1080,14 +1080,14 @@ gen_conditional_move (rtx cmp)
if (boolean_operator (cmp, VOIDmode))
{
- /* swap the operands to make const0 second */
+ /* Swap the operands to make const0 second. */
if (op0 == const0_rtx)
{
op0 = op1;
op1 = const0_rtx;
}
- /* if not comparing against zero, emit a comparison (subtract) */
+ /* If not comparing against zero, emit a comparison (subtract). */
if (op1 != const0_rtx)
{
op0 = expand_binop (SImode, sub_optab, op0, op1,
@@ -1097,7 +1097,7 @@ gen_conditional_move (rtx cmp)
}
else if (branch_operator (cmp, VOIDmode))
{
- /* swap the operands to make const0 second */
+ /* Swap the operands to make const0 second. */
if (op0 == const0_rtx)
{
op0 = op1;
@@ -1379,26 +1379,26 @@ xtensa_expand_block_move (rtx *operands)
int align = XINT (operands[3], 0);
int num_pieces, move_ratio;
- /* If this is not a fixed size move, just call memcpy */
+ /* If this is not a fixed size move, just call memcpy. */
if (!optimize || (GET_CODE (operands[2]) != CONST_INT))
return 0;
- /* Anything to move? */
+ /* Anything to move? */
if (bytes <= 0)
return 1;
if (align > MOVE_MAX)
align = MOVE_MAX;
- /* decide whether to expand inline based on the optimization level */
+ /* Decide whether to expand inline based on the optimization level. */
move_ratio = 4;
if (optimize > 2)
move_ratio = LARGEST_MOVE_RATIO;
- num_pieces = (bytes / align) + (bytes % align); /* close enough anyway */
+ num_pieces = (bytes / align) + (bytes % align); /* Close enough anyway. */
if (num_pieces >= move_ratio)
return 0;
- /* make sure the memory addresses are valid */
+ /* Make sure the memory addresses are valid. */
operands[0] = validize_mem (dest);
operands[1] = validize_mem (src);
@@ -1408,10 +1408,10 @@ xtensa_expand_block_move (rtx *operands)
}
-/* Emit a sequence of instructions to implement a block move, trying
- to hide load delay slots as much as possible. Load N values into
- temporary registers, store those N values, and repeat until the
- complete block has been moved. N=delay_slots+1 */
+/* Emit a sequence of instructions to implement a block move, trying
+ to hide load delay slots as much as possible. Load N values into
+ temporary registers, store those N values, and repeat until the
+ complete block has been moved. N=delay_slots+1. */
struct meminsnbuf
{
@@ -1467,7 +1467,7 @@ xtensa_emit_block_move (rtx *operands, rtx *tmpregs, int delay_slots)
if (bytes < item_size)
{
- /* find a smaller item_size which we can load & store */
+ /* Find a smaller item_size which we can load & store. */
item_size = bytes;
mode = xtensa_find_mode_for_size (item_size);
item_size = GET_MODE_SIZE (mode);
@@ -1475,7 +1475,7 @@ xtensa_emit_block_move (rtx *operands, rtx *tmpregs, int delay_slots)
stname = xtensa_st_opcodes[(int) mode];
}
- /* record the load instruction opcode and operands */
+ /* Record the load instruction opcode and operands. */
addr = plus_constant (from_addr, offset);
mem = gen_rtx_MEM (mode, addr);
if (! memory_address_p (mode, addr))
@@ -1485,7 +1485,7 @@ xtensa_emit_block_move (rtx *operands, rtx *tmpregs, int delay_slots)
ldinsns[n].operands[1] = mem;
sprintf (ldinsns[n].template, "%s\t%%0, %%1", ldname);
- /* record the store instruction opcode and operands */
+ /* Record the store instruction opcode and operands. */
addr = plus_constant (to_addr, offset);
mem = gen_rtx_MEM (mode, addr);
if (! memory_address_p (mode, addr))
@@ -1499,7 +1499,7 @@ xtensa_emit_block_move (rtx *operands, rtx *tmpregs, int delay_slots)
bytes -= item_size;
}
- /* now output the loads followed by the stores */
+ /* Now output the loads followed by the stores. */
for (n = 0; n < chunk_size; n++)
output_asm_insn (ldinsns[n].template, ldinsns[n].operands);
for (n = 0; n < chunk_size; n++)
@@ -1517,7 +1517,7 @@ xtensa_find_mode_for_size (unsigned item_size)
{
mode = VOIDmode;
- /* find mode closest to but not bigger than item_size */
+ /* Find mode closest to but not bigger than item_size. */
for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode))
if (GET_MODE_SIZE (tmode) <= item_size)
@@ -1531,7 +1531,7 @@ xtensa_find_mode_for_size (unsigned item_size)
&& xtensa_st_opcodes[(int) mode])
break;
- /* cannot load & store this mode; try something smaller */
+ /* Cannot load & store this mode; try something smaller. */
item_size -= 1;
}
@@ -1545,8 +1545,8 @@ xtensa_expand_nonlocal_goto (rtx *operands)
rtx goto_handler = operands[1];
rtx containing_fp = operands[3];
- /* generate a call to "__xtensa_nonlocal_goto" (in libgcc); the code
- is too big to generate in-line */
+ /* Generate a call to "__xtensa_nonlocal_goto" (in libgcc); the code
+ is too big to generate in-line. */
if (GET_CODE (containing_fp) != REG)
containing_fp = force_reg (Pmode, containing_fp);
@@ -1789,7 +1789,7 @@ override_options (void)
if (!TARGET_BOOLEANS && TARGET_HARD_FLOAT)
error ("boolean registers required for the floating-point option");
- /* set up the tables of ld/st opcode names for block moves */
+ /* Set up the tables of ld/st opcode names for block moves. */
xtensa_ld_opcodes[(int) SImode] = "l32i";
xtensa_ld_opcodes[(int) HImode] = "l16ui";
xtensa_ld_opcodes[(int) QImode] = "l8ui";
@@ -2366,7 +2366,7 @@ xtensa_builtin_saveregs (void)
if (gp_left == 0)
return const0_rtx;
- /* allocate the general-purpose register space */
+ /* Allocate the general-purpose register space. */
gp_regs = assign_stack_local
(BLKmode, MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD, -1);
set_mem_alias_set (gp_regs, get_varargs_alias_set ());
@@ -2662,8 +2662,8 @@ order_regs_for_local_alloc (void)
int i, num_arg_regs;
int nxt = 0;
- /* use the AR registers in increasing order (skipping a0 and a1)
- but save the incoming argument registers for a last resort */
+ /* Use the AR registers in increasing order (skipping a0 and a1)
+ but save the incoming argument registers for a last resort. */
num_arg_regs = current_function_args_info.arg_words;
if (num_arg_regs > MAX_ARGS_IN_REGISTERS)
num_arg_regs = MAX_ARGS_IN_REGISTERS;
@@ -2672,11 +2672,11 @@ order_regs_for_local_alloc (void)
for (i = 0; i < num_arg_regs; i++)
reg_alloc_order[nxt++] = GP_ARG_FIRST + i;
- /* list the coprocessor registers in order */
+ /* List the coprocessor registers in order. */
for (i = 0; i < BR_REG_NUM; i++)
reg_alloc_order[nxt++] = BR_REG_FIRST + i;
- /* list the FP registers in order for now */
+ /* List the FP registers in order for now. */
for (i = 0; i < 16; i++)
reg_alloc_order[nxt++] = FP_REG_FIRST + i;
@@ -2821,7 +2821,7 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int *total)
case LSHIFTRT:
case ROTATE:
case ROTATERT:
- /* no way to tell if X is the 2nd operand so be conservative */
+ /* No way to tell if X is the 2nd operand so be conservative. */
default: break;
}
if (xtensa_simm12b (INTVAL (x)))
@@ -2948,7 +2948,7 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int *total)
return true;
}
}
- /* fall through */
+ /* Fall through. */
case UDIV:
case UMOD:
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index dae6810ea00..a7f470ec0b5 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -142,10 +142,10 @@ extern unsigned xtensa_current_frame_size;
in instructions that operate on numbered bit-fields. */
#define BITS_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)
-/* Define this if most significant byte of a word is the lowest numbered. */
+/* Define this if most significant byte of a word is the lowest numbered. */
#define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)
-/* Define this if most significant word of a multiword number is the lowest. */
+/* Define this if most significant word of a multiword number is the lowest. */
#define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)
#define MAX_BITS_PER_WORD 32
@@ -271,11 +271,11 @@ extern unsigned xtensa_current_frame_size;
#define FIRST_PSEUDO_REGISTER 36
-/* Return the stabs register number to use for REGNO. */
+/* Return the stabs register number to use for REGNO. */
#define DBX_REGISTER_NUMBER(REGNO) xtensa_dbx_register_number (REGNO)
/* 1 for registers that have pervasive standard uses
- and are not available for the register allocator. */
+ and are not available for the register allocator. */
#define FIXED_REGISTERS \
{ \
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
@@ -326,18 +326,18 @@ extern unsigned xtensa_current_frame_size;
giving preference to call-used registers. To minimize window
overflows for the AR registers, we want to give preference to the
lower-numbered AR registers. For other register files, which are
- not windowed, we still prefer call-used registers, if there are any. */
+ not windowed, we still prefer call-used registers, if there are any. */
extern const char xtensa_leaf_regs[FIRST_PSEUDO_REGISTER];
#define LEAF_REGISTERS xtensa_leaf_regs
/* For Xtensa, no remapping is necessary, but this macro must be
- defined if LEAF_REGISTERS is defined. */
+ defined if LEAF_REGISTERS is defined. */
#define LEAF_REG_REMAP(REGNO) (REGNO)
-/* this must be declared if LEAF_REGISTERS is set */
+/* This must be declared if LEAF_REGISTERS is set. */
extern int leaf_function;
-/* Internal macros to classify a register number. */
+/* Internal macros to classify a register number. */
/* 16 address registers + fake registers */
#define GP_REG_FIRST 0
@@ -372,7 +372,7 @@ extern int leaf_function;
((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
/* Value is 1 if hard register REGNO can hold a value of machine-mode
- MODE. */
+ MODE. */
extern char xtensa_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER];
#define HARD_REGNO_MODE_OK(REGNO, MODE) \
@@ -397,7 +397,7 @@ extern char xtensa_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER];
/* The register number of the frame pointer register, which is used to
access automatic variables in the stack frame. For Xtensa, this
register never appears in the output. It is always eliminated to
- either the stack pointer or the hard frame pointer. */
+ either the stack pointer or the hard frame pointer. */
#define FRAME_POINTER_REGNUM (GP_REG_FIRST + 16)
/* Value should be nonzero if functions must have frame pointers.
@@ -518,7 +518,7 @@ extern const enum reg_class xtensa_regno_to_class[FIRST_PSEUDO_REGISTER];
/* SMALL_REGISTER_CLASSES is required for Xtensa, because all of the
16 AR registers may be explicitly used in the RTL, as either
- incoming or outgoing arguments. */
+ incoming or outgoing arguments. */
#define SMALL_REGISTER_CLASSES 1
@@ -599,7 +599,7 @@ extern enum reg_class xtensa_char_to_class[256];
the meantime, the constraints are checked and none match. The
solution seems to be to simply skip the offset check here. The
address will be checked anyway because of the code in
- GO_IF_LEGITIMATE_ADDRESS. */
+ GO_IF_LEGITIMATE_ADDRESS. */
#define EXTRA_CONSTRAINT(OP, CODE) \
((GET_CODE (OP) != MEM) ? \
@@ -714,7 +714,7 @@ extern enum reg_class xtensa_char_to_class[256];
/* Define how to find the value returned by a library function
assuming the value has mode MODE. Because we have defined
PROMOTE_FUNCTION_RETURN, we have to perform the same promotions as
- PROMOTE_MODE. */
+ PROMOTE_MODE. */
#define XTENSA_LIBCALL_VALUE(MODE, OUTGOINGP) \
gen_rtx_REG ((GET_MODE_CLASS (MODE) == MODE_INT \
&& GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
@@ -750,7 +750,7 @@ extern enum reg_class xtensa_char_to_class[256];
be recognized by this macro. If the machine has register windows,
so that the caller and the called function use different registers
for the return value, this macro should recognize only the caller's
- register numbers. */
+ register numbers. */
#define FUNCTION_VALUE_REGNO_P(N) \
((N) == GP_RETURN)
@@ -759,7 +759,7 @@ extern enum reg_class xtensa_char_to_class[256];
does *not* include implicit arguments such as the static chain and
the structure-value address. On many machines, no registers can be
used for this purpose since all function arguments are pushed on
- the stack. */
+ the stack. */
#define FUNCTION_ARG_REGNO_P(N) \
((N) >= GP_OUTGOING_ARG_FIRST && (N) <= GP_OUTGOING_ARG_LAST)
@@ -767,14 +767,14 @@ extern enum reg_class xtensa_char_to_class[256];
during the scan of that argument list. This data type should
hold all necessary information about the function itself
and about the args processed so far, enough to enable macros
- such as FUNCTION_ARG to determine where the next arg should go. */
+ such as FUNCTION_ARG to determine where the next arg should go. */
typedef struct xtensa_args {
int arg_words; /* # total words the arguments take */
} CUMULATIVE_ARGS;
/* Initialize a variable CUM of type CUMULATIVE_ARGS
for a call to a function whose data type is FNTYPE.
- For a library call, FNTYPE is 0. */
+ For a library call, FNTYPE is 0. */
#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
init_cumulative_args (&CUM, FNTYPE, LIBNAME)
@@ -816,7 +816,7 @@ typedef struct xtensa_args {
This differs from the default in that it does not check if the padding
and mode of the type are such that a copy into a register would put it
- into the wrong part of the register. */
+ into the wrong part of the register. */
#define MUST_PASS_IN_STACK(MODE, TYPE) \
((TYPE) != 0 \
@@ -835,7 +835,7 @@ typedef struct xtensa_args {
values contain window size information in the two most significant
bits; we assume that _mcount will mask off those bits. The call to
_mcount uses a window size of 8 to make sure that it doesn't clobber
- any incoming argument values. */
+ any incoming argument values. */
#define NO_PROFILE_COUNTERS 1
@@ -865,7 +865,7 @@ typedef struct xtensa_args {
from the entry instruction at the target and the current frame is
adjusted to match. The trampoline then transfers control to the
instruction following the entry at the target. Note: this assumes
- that the target begins with an entry instruction. */
+ that the target begins with an entry instruction. */
/* minimum frame = reg save area (4 words) plus static chain (1 word)
and the total number of words must be a multiple of 128 bits */
@@ -934,7 +934,7 @@ typedef struct xtensa_args {
code for a call to '__builtin_saveregs'. This code will be moved
to the very beginning of the function, before any parameter access
are made. The return value of this function should be an RTX that
- contains the value to use as the return of '__builtin_saveregs'. */
+ contains the value to use as the return of '__builtin_saveregs'. */
#define EXPAND_BUILTIN_SAVEREGS \
xtensa_builtin_saveregs
@@ -962,7 +962,7 @@ typedef struct xtensa_args {
specify whether to start from the stack pointer or frame pointer. That
would also allow us to skip the machine->accesses_prev_frame stuff that
we currently need to ensure that there is a frame pointer when these
- builtin functions are used. */
+ builtin functions are used. */
#define SETUP_FRAME_ADDRESSES xtensa_setup_frame_addresses
@@ -976,14 +976,14 @@ typedef struct xtensa_args {
macro is used for continuing to walk back up the stack, so it must
return the stack pointer address. Thus, there is some inconsistency
here in that __builtin_frame_address will return the frame pointer
- when count == 0 and the stack pointer when count > 0. */
+ when count == 0 and the stack pointer when count > 0. */
#define DYNAMIC_CHAIN_ADDRESS(frame) \
gen_rtx (PLUS, Pmode, frame, \
gen_rtx_CONST_INT (VOIDmode, -3 * UNITS_PER_WORD))
/* Define this if the return address of a particular stack frame is
- accessed from the frame pointer of the previous stack frame. */
+ accessed from the frame pointer of the previous stack frame. */
#define RETURN_ADDR_IN_PREVIOUS_FRAME
/* A C expression whose value is RTL representing the value of the
@@ -998,7 +998,7 @@ typedef struct xtensa_args {
be either a suitable hard register or a pseudo register that has
been allocated such a hard register. The difference between an
index register and a base register is that the index register may
- be scaled. */
+ be scaled. */
#define REGNO_OK_FOR_BASE_P(NUM) \
(GP_REG_P (NUM) || GP_REG_P ((unsigned) reg_renumber[NUM]))
@@ -1012,7 +1012,7 @@ typedef struct xtensa_args {
must be controlled by `REG_OK_STRICT'. This usually requires two
variant definitions, of which `REG_OK_STRICT' controls the one
actually used. The difference between an index register and a base
- register is that the index register may be scaled. */
+ register is that the index register may be scaled. */
#ifdef REG_OK_STRICT
@@ -1091,7 +1091,7 @@ typedef struct xtensa_args {
|| (GET_CODE (X) == CONST)))
/* Nonzero if the constant value X is a legitimate general operand.
- It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
+ It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
#define LEGITIMATE_CONSTANT_P(X) 1
/* A C expression that is nonzero if X is a legitimate immediate
@@ -1179,7 +1179,7 @@ typedef struct xtensa_args {
#define SHIFT_COUNT_TRUNCATED 1
/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
- is done just by pretending it is already truncated. */
+ is done just by pretending it is already truncated. */
#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
/* Specify the machine mode that pointers have.
@@ -1245,7 +1245,7 @@ typedef struct xtensa_args {
/* Control the assembler format that we output. */
/* How to refer to registers in assembler output.
- This sequence is indexed by compiler's hard-register-number (see above). */
+ This sequence is indexed by compiler's hard-register-number (see above). */
#define REGISTER_NAMES \
{ \
"a0", "sp", "a2", "a3", "a4", "a5", "a6", "a7", \
@@ -1259,7 +1259,7 @@ typedef struct xtensa_args {
/* If defined, a C initializer for an array of structures containing a
name and a register number. This macro defines additional names
for hard registers, thus allowing the 'asm' option in declarations
- to refer to registers using alternate names. */
+ to refer to registers using alternate names. */
#define ADDITIONAL_REGISTER_NAMES \
{ \
{ "a1", 1 + GP_REG_FIRST } \
@@ -1302,7 +1302,7 @@ typedef struct xtensa_args {
LOCAL_LABEL_PREFIX, VALUE)
/* This is how to output an element of a case-vector that is relative.
- This is used for pc-relative code. */
+ This is used for pc-relative code. */
#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \
do { \
fprintf (STREAM, "%s%sL%u-%sL%u\n", integer_asm_op (4, TRUE), \
@@ -1332,7 +1332,7 @@ typedef struct xtensa_args {
/* Define output to appear before the constant pool. If the function
has been assigned to a specific ELF section, or if it goes into a
unique section, set the name of that section to be the literal
- prefix. */
+ prefix. */
#define ASM_OUTPUT_POOL_PROLOGUE(FILE, FUNNAME, FUNDECL, SIZE) \
do { \
tree fnsection; \
@@ -1367,7 +1367,7 @@ typedef struct xtensa_args {
goto JUMPTO; \
} while (0)
-/* How to start an assembler comment. */
+/* How to start an assembler comment. */
#define ASM_COMMENT_START "#"
/* Exception handling TODO!! */
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 9e2541374f2..8b43d6af24e 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -154,7 +154,7 @@ read_counts_file (void)
counts_entry_t *summaried = NULL;
unsigned seen_summary = 0;
gcov_unsigned_t tag;
- int error = 0;
+ int is_error = 0;
if (!gcov_open (da_file_name, 1))
return;
@@ -250,17 +250,26 @@ read_counts_file (void)
entry->summary.num = n_counts;
entry->counts = xcalloc (n_counts, sizeof (gcov_type));
}
- else if (entry->checksum != checksum
- || entry->summary.num != n_counts)
+ else if (entry->checksum != checksum)
{
- warning ("coverage mismatch for function %u", fn_ident);
+ error ("coverage mismatch for function %u while reading execution counters.",
+ fn_ident);
+ error ("checksum is %x instead of %x", entry->checksum, checksum);
+ htab_delete (counts_hash);
+ break;
+ }
+ else if (entry->summary.num != n_counts)
+ {
+ error ("coverage mismatch for function %u while reading execution counters.",
+ fn_ident);
+ error ("number of counters is %d instead of %d", entry->summary.num, n_counts);
htab_delete (counts_hash);
break;
}
else if (elt.ctr >= GCOV_COUNTERS_SUMMABLE)
{
- warning ("cannot merge separate %s counters for function %u",
- ctr_names[elt.ctr], fn_ident);
+ error ("cannot merge separate %s counters for function %u",
+ ctr_names[elt.ctr], fn_ident);
goto skip_merge;
}
@@ -278,14 +287,14 @@ read_counts_file (void)
skip_merge:;
}
gcov_sync (offset, length);
- if ((error = gcov_is_error ()))
+ if ((is_error = gcov_is_error ()))
break;
}
if (!gcov_is_eof ())
{
- warning (error < 0 ? "`%s' has overflowed" : "`%s' is corrupted",
- da_file_name);
+ error (is_error < 0 ? "`%s' has overflowed" : "`%s' is corrupted",
+ da_file_name);
htab_delete (counts_hash);
}
@@ -299,6 +308,7 @@ get_coverage_counts (unsigned counter, unsigned expected,
const struct gcov_ctr_summary **summary)
{
counts_entry_t *entry, elt;
+ gcov_unsigned_t checksum = -1;
/* No hash table, no counts. */
if (!counts_hash)
@@ -321,12 +331,22 @@ get_coverage_counts (unsigned counter, unsigned expected,
return 0;
}
- if (expected != entry->summary.num
- || compute_checksum () != entry->checksum)
+ checksum = compute_checksum ();
+ if (entry->checksum != checksum)
{
- warning ("coverage mismatch for `%s'", IDENTIFIER_POINTER
- (DECL_ASSEMBLER_NAME (current_function_decl)));
- return NULL;
+ error ("coverage mismatch for function '%s' while reading counter '%s'.",
+ IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)),
+ ctr_names[counter]);
+ error ("checksum is %x instead of %x", entry->checksum, checksum);
+ return 0;
+ }
+ else if (entry->summary.num != expected)
+ {
+ error ("coverage mismatch for function '%s' while reading counter '%s'.",
+ IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)),
+ ctr_names[counter]);
+ error ("number of counters is %d instead of %d", entry->summary.num, expected);
+ return 0;
}
if (summary)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 823c9876de0..8641587fcf4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -5,6 +5,62 @@
* method.c (use_thunk): Set CALL_FROM_THUNK on the call to the
actual function.
+2003-12-30 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/13507
+ * decl.c (duplicate_decls): Use build_type_attribute_variant to
+ merge attributes.
+
+ PR c++/13494
+ * tree.c (build_cplus_array_type_1): Only build a minimal array
+ type for dependent types or domains.
+
+2003-12-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/12774
+ * typeck.c (comp_array_types): Fold non-dependent domains for
+ ABI-1.
+
+2003-12-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/13289
+ * semantics.c (finish_id_expression): Only check if the type of
+ a template argument is integral or enumeration when it is not
+ dependent.
+
+2003-12-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/12403
+ * parser.c (cp_parser_template_declaration_after_export): Set up
+ template specialization scope in case of explicit specialization.
+
+2003-12-28 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/13081
+ * decl.c (duplicate_decls): Preserve inline-ness when redeclaring
+ a function template.
+
+ PR c++/12613
+ * decl.c (reshape_init): Reject GNU colon-style designated
+ initializers in arrays.
+
+ PR c++/13009
+ * call.c (build_special_member_call): Do not assume that we have a
+ pointer to the complete object in an assignment operator.
+
+2003-12-28 Roger Sayle <roger@eyesopen.com>
+
+ PR c++/13070
+ * decl.c (duplicate_decls): When setting the type of an anticipated
+ declaration, merge the existing type attributes.
+
+2003-12-25 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR c++/13268, c++/13339
+ * class.c (add_method): Return early when method is error_mark_node.
+ * pt.c (tsubst_friend_function): Return early when new_friend is
+ error_mark_node.
+
2003-12-23 Mark Mitchell <mark@codesourcery.com>
* cp-lang.c (cp_expr_size): Return zero for empty classes.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 2dc4f2240c6..5e759259015 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4865,14 +4865,23 @@ build_special_member_call (tree instance, tree name, tree args,
|| name == deleting_dtor_identifier)
my_friendly_assert (args == NULL_TREE, 20020712);
- /* We must perform the conversion here so that we do not
- subsequently check to see whether BINFO is an accessible
- base. (It is OK for a constructor to call a constructor in
- an inaccessible base as long as the constructor being called
- is accessible.) */
+ /* Convert to the base class, if necessary. */
if (!same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (instance), BINFO_TYPE (binfo)))
- instance = convert_to_base_statically (instance, binfo);
+ {
+ if (name != ansi_assopname (NOP_EXPR))
+ /* For constructors and destructors, either the base is
+ non-virtual, or it is virtual but we are doing the
+ conversion from a constructor or destructor for the
+ complete object. In either case, we can convert
+ statically. */
+ instance = convert_to_base_statically (instance, binfo);
+ else
+ /* However, for assignment operators, we must convert
+ dynamically if the base is virtual. */
+ instance = build_base_path (PLUS_EXPR, instance,
+ binfo, /*nonnull=*/1);
+ }
}
my_friendly_assert (instance != NULL_TREE, 20020712);
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index d11029567c4..2928dd33071 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -725,12 +725,18 @@ modify_vtable_entry (tree t,
void
add_method (tree type, tree method, int error_p)
{
- int using = (DECL_CONTEXT (method) != type);
+ int using;
int len;
int slot;
tree method_vec;
- int template_conv_p = (TREE_CODE (method) == TEMPLATE_DECL
- && DECL_TEMPLATE_CONV_FN_P (method));
+ int template_conv_p;
+
+ if (method == error_mark_node)
+ return;
+
+ using = (DECL_CONTEXT (method) != type);
+ template_conv_p = (TREE_CODE (method) == TEMPLATE_DECL
+ && DECL_TEMPLATE_CONV_FN_P (method));
if (!CLASSTYPE_METHOD_VEC (type))
/* Make a new method vector. We start with 8 entries. We must
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index abcdd9e9b52..92f3a75975c 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1261,7 +1261,14 @@ duplicate_decls (tree newdecl, tree olddecl)
/* Even if the types match, prefer the new declarations type
for anticipated built-ins, for exception lists, etc... */
else if (DECL_ANTICIPATED (olddecl))
- TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
+ {
+ tree type = TREE_TYPE (newdecl);
+ tree attribs = (*targetm.merge_type_attributes)
+ (TREE_TYPE (olddecl), type);
+
+ type = build_type_attribute_variant (type, attribs);
+ TREE_TYPE (newdecl) = TREE_TYPE (olddecl) = type;
+ }
/* Whether or not the builtin can throw exceptions has no
bearing on this declarator. */
@@ -1589,6 +1596,14 @@ duplicate_decls (tree newdecl, tree olddecl)
= DECL_SOURCE_LOCATION (newdecl);
}
+ if (DECL_FUNCTION_TEMPLATE_P (newdecl))
+ {
+ DECL_INLINE (DECL_TEMPLATE_RESULT (olddecl))
+ |= DECL_INLINE (DECL_TEMPLATE_RESULT (newdecl));
+ DECL_DECLARED_INLINE_P (DECL_TEMPLATE_RESULT (olddecl))
+ |= DECL_DECLARED_INLINE_P (DECL_TEMPLATE_RESULT (newdecl));
+ }
+
return olddecl;
}
@@ -4337,7 +4352,17 @@ reshape_init (tree type, tree *initp)
TREE_CHAIN (element_init) = CONSTRUCTOR_ELTS (new_init);
CONSTRUCTOR_ELTS (new_init) = element_init;
if (TREE_PURPOSE (element_init))
- index = TREE_PURPOSE (element_init);
+ {
+ tree next_index = TREE_PURPOSE (element_init);
+ if (TREE_CODE (next_index) == IDENTIFIER_NODE)
+ {
+ error ("name `%D' used in a GNU-style designated "
+ "initializer for an array", next_index);
+ TREE_PURPOSE (element_init) = NULL_TREE;
+ }
+ else
+ index = next_index;
+ }
}
}
else
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index eae46cf81ea..46907ecb5bb 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -13961,19 +13961,23 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p)
if (!cp_parser_require (parser, CPP_LESS, "`<'"))
return;
- /* Parse the template parameters. */
- begin_template_parm_list ();
/* If the next token is `>', then we have an invalid
specialization. Rather than complain about an invalid template
parameter, issue an error message here. */
if (cp_lexer_next_token_is (parser->lexer, CPP_GREATER))
{
cp_parser_error (parser, "invalid explicit specialization");
+ begin_specialization ();
parameter_list = NULL_TREE;
}
else
- parameter_list = cp_parser_template_parameter_list (parser);
- parameter_list = end_template_parm_list (parameter_list);
+ {
+ /* Parse the template parameters. */
+ begin_template_parm_list ();
+ parameter_list = cp_parser_template_parameter_list (parser);
+ parameter_list = end_template_parm_list (parameter_list);
+ }
+
/* Look for the `>'. */
cp_parser_skip_until_found (parser, CPP_GREATER, "`>'");
/* We just processed one more parameter list. */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index e7a886380c2..3c0e7d80213 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4897,6 +4897,9 @@ tsubst_friend_function (tree decl, tree args)
Then, in S<int>, template <class U> void f(int, U) is not an
instantiation of anything. */
+ if (new_friend == error_mark_node)
+ return error_mark_node;
+
DECL_USE_TEMPLATE (new_friend) = 0;
if (TREE_CODE (decl) == TEMPLATE_DECL)
{
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index c9a4a68a40a..4cf0261aff2 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2400,6 +2400,7 @@ finish_id_expression (tree id_expression,
if (TREE_CODE (decl) == TEMPLATE_PARM_INDEX)
decl = TEMPLATE_PARM_DECL (decl);
if (integral_constant_expression_p
+ && !dependent_type_p (TREE_TYPE (decl))
&& !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (decl)))
{
if (!allow_non_integral_constant_expression_p)
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 426c3d7c9ed..bedbbe96b44 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -363,14 +363,9 @@ build_cplus_array_type_1 (tree elt_type, tree index_type)
if (elt_type == error_mark_node || index_type == error_mark_node)
return error_mark_node;
- /* Don't do the minimal thing just because processing_template_decl is
- set; we want to give string constants the right type immediately, so
- we don't have to fix them up at instantiation time. */
- if ((processing_template_decl
- && index_type && TYPE_MAX_VALUE (index_type)
- && TREE_CODE (TYPE_MAX_VALUE (index_type)) != INTEGER_CST)
- || uses_template_parms (elt_type)
- || (index_type && uses_template_parms (index_type)))
+ if (dependent_type_p (elt_type)
+ || (index_type
+ && value_dependent_expression_p (TYPE_MAX_VALUE (index_type))))
{
t = make_node (ARRAY_TYPE);
TREE_TYPE (t) = elt_type;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 3cdfdc297d8..ff397c0417d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -857,6 +857,7 @@ comp_array_types (tree t1, tree t2, bool allow_redeclaration)
{
tree d1;
tree d2;
+ tree max1, max2;
if (t1 == t2)
return true;
@@ -887,8 +888,27 @@ comp_array_types (tree t1, tree t2, bool allow_redeclaration)
return allow_redeclaration;
/* Check that the dimensions are the same. */
- return (cp_tree_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2))
- && cp_tree_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2)));
+
+ if (!cp_tree_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2)))
+ return false;
+ max1 = TYPE_MAX_VALUE (d1);
+ max2 = TYPE_MAX_VALUE (d2);
+ if (processing_template_decl && !abi_version_at_least (2)
+ && !value_dependent_expression_p (max1)
+ && !value_dependent_expression_p (max2))
+ {
+ /* With abi-1 we do not fold non-dependent array bounds, (and
+ consequently mangle them incorrectly). We must therefore
+ fold them here, to verify the domains have the same
+ value. */
+ max1 = fold (max1);
+ max2 = fold (max2);
+ }
+
+ if (!cp_tree_equal (max1, max2))
+ return false;
+
+ return true;
}
/* Return true if T1 and T2 are related as allowed by STRICT. STRICT
diff --git a/gcc/defaults.h b/gcc/defaults.h
index d540e2809ed..afe788cdd26 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -485,7 +485,7 @@ do { fputs (integer_asm_op (POINTER_SIZE / UNITS_PER_WORD, TRUE), FILE); \
PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way.
This is one long line cause VAXC can't handle a \-newline. */
-#if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO) + defined (VMS_DEBUGGING_INFO))
+#if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO) + defined (VMS_DEBUGGING_INFO))
#ifndef PREFERRED_DEBUGGING_TYPE
You Lose! You must define PREFERRED_DEBUGGING_TYPE!
#endif /* no PREFERRED_DEBUGGING_TYPE */
diff --git a/gcc/doc/c-tree.texi b/gcc/doc/c-tree.texi
index 31be1626e5c..9151fec67f5 100644
--- a/gcc/doc/c-tree.texi
+++ b/gcc/doc/c-tree.texi
@@ -788,7 +788,7 @@ This predicate holds whenever its argument represents a class-type with
default constructor.
@item CLASSTYPE_HAS_MUTABLE
-@item TYPE_HAS_MUTABLE_P
+@itemx TYPE_HAS_MUTABLE_P
These predicates hold for a class-type having a mutable data member.
@item CLASSTYPE_NON_POD_P
@@ -1991,7 +1991,7 @@ real part and the second operand is the imaginary part.
These nodes represent the conjugate of their operand.
@item REALPART_EXPR
-@item IMAGPART_EXPR
+@itemx IMAGPART_EXPR
These nodes represent respectively the real and the imaginary parts
of complex numbers (their sole argument).
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index 2db1ee1ff11..0ab1b3203ec 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -2086,7 +2086,7 @@ runtime is used, this macro is not defined, so that you can use this
macro to determine which runtime (NeXT or GNU) is being used.
@item __LP64__
-@item _LP64
+@itemx _LP64
These macros are defined, with value 1, if (and only if) the compilation
is for a target where @code{long int} and pointer both use 64-bits and
@code{int} uses 32-bit.
diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi
index 4d509e859d1..2e7f50e37a6 100644
--- a/gcc/doc/cppopts.texi
+++ b/gcc/doc/cppopts.texi
@@ -456,8 +456,6 @@ Append @var{dir} to the prefix specified previously with
path. @option{-iwithprefixbefore} puts it in the same place @option{-I}
would; @option{-iwithprefix} puts it where @option{-idirafter} would.
-Use of these options is discouraged.
-
@item -isystem @var{dir}
@opindex isystem
Search @var{dir} for header files, after all directories specified by
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 8c94efff1e8..ce8e77b5320 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1077,7 +1077,7 @@ not specified is @samp{misc,tree,gc,rtlflag}; the checks @samp{rtl},
@samp{gcac} and @samp{valgrind} are very expensive.
@item --enable-coverage
-@item --enable-coverage=@var{level}
+@itemx --enable-coverage=@var{level}
With this option, the compiler is built to collect self coverage
information, every time it is run. This is for internal development
purposes, and only works when the compiler is being built with gcc. The
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 86ce1719199..9e3d915c0a3 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -252,7 +252,7 @@ in the following sections.
-feliminate-unused-debug-symbols -fmem-report -fprofile-arcs @gol
-frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
-ftest-coverage -ftime-report @gol
--g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 @gol
+-g -g@var{level} -gcoff -gdwarf-2 @gol
-ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+ @gol
-p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol
-print-multi-directory -print-multi-lib @gol
@@ -281,6 +281,7 @@ in the following sections.
-fno-trapping-math -fno-zero-initialized-in-bss @gol
-fomit-frame-pointer -foptimize-register-move @gol
-foptimize-sibling-calls -fprefetch-loop-arrays @gol
+-fprofile-generate -fprofile-use @gol
-freduce-all-givs -fregmove -frename-registers @gol
-freorder-blocks -freorder-functions @gol
-frerun-cse-after-loop -frerun-loop-opt @gol
@@ -1048,7 +1049,7 @@ names @samp{c9x} and @samp{iso9899:199x} are deprecated.
Default, ISO C90 plus GNU extensions (including some C99 features).
@item gnu99
-@item gnu9x
+@itemx gnu9x
ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC,
this will become the default. The name @samp{gnu9x} is deprecated.
@@ -3024,8 +3025,7 @@ makes debugging work better in GDB but will probably make other debuggers
crash or
refuse to read the program. If you want to control for certain whether
to generate the extra information, use @option{-gstabs+}, @option{-gstabs},
-@option{-gxcoff+}, @option{-gxcoff}, @option{-gdwarf-1+}, @option{-gdwarf-1},
-or @option{-gvms} (see below).
+@option{-gxcoff+}, @option{-gxcoff}, or @option{-gvms} (see below).
Unlike most other C compilers, GCC allows you to use @option{-g} with
@option{-O}. The shortcuts taken by optimized code may occasionally
@@ -3087,23 +3087,6 @@ use of these extensions is likely to make other debuggers crash or
refuse to read the program, and may cause assemblers other than the GNU
assembler (GAS) to fail with an error.
-@item -gdwarf
-@opindex gdwarf
-Produce debugging information in DWARF version 1 format (if that is
-supported). This is the format used by SDB on most System V Release 4
-systems.
-
-This option is deprecated.
-
-@item -gdwarf+
-@opindex gdwarf+
-Produce debugging information in DWARF version 1 format (if that is
-supported), using GNU extensions understood only by the GNU debugger
-(GDB)@. The use of these extensions is likely to make other debuggers
-crash or refuse to read the program.
-
-This option is deprecated.
-
@item -gdwarf-2
@opindex gdwarf-2
Produce debugging information in DWARF version 2 format (if that is
@@ -3133,9 +3116,9 @@ present in the program. Some debuggers support macro expansion when
you use @option{-g3}.
Note that in order to avoid confusion between DWARF1 debug level 2,
-and DWARF2, neither @option{-gdwarf} nor @option{-gdwarf-2} accept
-a concatenated debug level. Instead use an additional @option{-g@var{level}}
-option to change the debug level for DWARF1 or DWARF2.
+and DWARF2 @option{-gdwarf-2} does not accept a concatenated debug
+level. Instead use an additional @option{-g@var{level}} option to
+change the debug level for DWARF2.
@item -feliminate-dwarf2-dups
@opindex feliminate-dwarf2-dups
@@ -4377,6 +4360,21 @@ and occasionally eliminate the copy.
Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
+@item -fprofile-generate
+@opindex fprofile-generate
+Enable options usually used for instrumenting application to produce profile usefull
+for later recompilation profile feedback based optimization.
+
+The following options are enabled: @code{-fprofile-arcs}, @code{-fprofile-values}, @code{-fvpt}
+
+@item -fprofile-use
+@opindex fprofile-use
+Enable profile feedback directed optimizations, and optimizations
+generally profitable only with profile feedback available.
+
+The following options are enabled: @code{-fbranch-probabilities},
+@code{-fvpt}, @code{-funroll-loops}, @code{-fpeel-loops}, @code{-ftracer}.
+
@end table
The following options control compiler behavior regarding floating
@@ -7815,62 +7813,62 @@ This specifies the @var{executable} that will be loading the build
output file being linked. See man ld(1) for more information.
@item -allowable_client @var{client_name}
-@item -arch_only
-
-@item -client_name
-@item -compatibility_version
-@item -current_version
-@item -dependency-file
-@item -dylib_file
-@item -dylinker_install_name
-@item -dynamic
-@item -dynamiclib
-@item -exported_symbols_list
-@item -filelist
-@item -flat_namespace
-@item -force_cpusubtype_ALL
-@item -force_flat_namespace
-@item -headerpad_max_install_names
-@item -image_base
-@item -init
-@item -install_name
-@item -keep_private_externs
-@item -multi_module
-@item -multiply_defined
-@item -multiply_defined_unused
-@item -noall_load
-@item -nofixprebinding
-@item -nomultidefs
-@item -noprebind
-@item -noseglinkedit
-@item -pagezero_size
-@item -prebind
-@item -prebind_all_twolevel_modules
-@item -private_bundle
-@item -read_only_relocs
-@item -sectalign
-@item -sectobjectsymbols
-@item -whyload
-@item -seg1addr
-@item -sectcreate
-@item -sectobjectsymbols
-@item -sectorder
-@item -seg_addr_table
-@item -seg_addr_table_filename
-@item -seglinkedit
-@item -segprot
-@item -segs_read_only_addr
-@item -segs_read_write_addr
-@item -single_module
-@item -static
-@item -sub_library
-@item -sub_umbrella
-@item -twolevel_namespace
-@item -umbrella
-@item -undefined
-@item -unexported_symbols_list
-@item -weak_reference_mismatches
-@item -whatsloaded
+@itemx -arch_only
+
+@itemx -client_name
+@itemx -compatibility_version
+@itemx -current_version
+@itemx -dependency-file
+@itemx -dylib_file
+@itemx -dylinker_install_name
+@itemx -dynamic
+@itemx -dynamiclib
+@itemx -exported_symbols_list
+@itemx -filelist
+@itemx -flat_namespace
+@itemx -force_cpusubtype_ALL
+@itemx -force_flat_namespace
+@itemx -headerpad_max_install_names
+@itemx -image_base
+@itemx -init
+@itemx -install_name
+@itemx -keep_private_externs
+@itemx -multi_module
+@itemx -multiply_defined
+@itemx -multiply_defined_unused
+@itemx -noall_load
+@itemx -nofixprebinding
+@itemx -nomultidefs
+@itemx -noprebind
+@itemx -noseglinkedit
+@itemx -pagezero_size
+@itemx -prebind
+@itemx -prebind_all_twolevel_modules
+@itemx -private_bundle
+@itemx -read_only_relocs
+@itemx -sectalign
+@itemx -sectobjectsymbols
+@itemx -whyload
+@itemx -seg1addr
+@itemx -sectcreate
+@itemx -sectobjectsymbols
+@itemx -sectorder
+@itemx -seg_addr_table
+@itemx -seg_addr_table_filename
+@itemx -seglinkedit
+@itemx -segprot
+@itemx -segs_read_only_addr
+@itemx -segs_read_write_addr
+@itemx -single_module
+@itemx -static
+@itemx -sub_library
+@itemx -sub_umbrella
+@itemx -twolevel_namespace
+@itemx -umbrella
+@itemx -undefined
+@itemx -unexported_symbols_list
+@itemx -weak_reference_mismatches
+@itemx -whatsloaded
@opindex allowable_client
@opindex arch_only
@@ -7929,7 +7927,7 @@ output file being linked. See man ld(1) for more information.
@opindex weak_reference_mismatches
@opindex whatsloaded
-This options are available for Darwin linker. Darwin linker man page
+These options are available for Darwin linker. Darwin linker man page
describes them in detail.
@end table
@@ -8588,7 +8586,7 @@ and will not be binary compatible with structures in code compiled
without that switch.
@item -m96bit-long-double
-@item -m128bit-long-double
+@itemx -m128bit-long-double
@opindex m96bit-long-double
@opindex m128bit-long-double
These switches control the size of @code{long double} type. The i386
@@ -9387,7 +9385,7 @@ Supported values for @var{cpu_type} are
@table @samp
@item ev4
-@item ev45
+@itemx ev45
@itemx 21064
Schedules as an EV4 and has no instruction set extensions.
@@ -9409,7 +9407,7 @@ Schedules as an EV5 and supports the BWX and MAX extensions.
Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
@item ev67
-@item 21264a
+@itemx 21264a
Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
@end table
@@ -9659,7 +9657,7 @@ parameters for machine type @var{cpu_type}. Supported values for
TMS320C40.
@item -mbig-memory
-@item -mbig
+@itemx -mbig
@itemx -msmall-memory
@itemx -msmall
@opindex mbig-memory
@@ -10751,7 +10749,7 @@ Use 32-bit @code{int}.
Use 64-bit @code{float}. This is the default.
@item -mfloat32
-@item -mno-float64
+@itemx -mno-float64
@opindex mfloat32
@opindex mno-float64
Use 32-bit @code{float}.
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index 5e3618f78b3..33706a35010 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -1439,7 +1439,7 @@ Constant integer 1
A floating point constant 0.0
@end table
-@item IBM RS6000---@file{rs6000.h}
+@item PowerPC and IBM RS6000---@file{rs6000.h}
@table @code
@item b
Address base register
@@ -1447,6 +1447,9 @@ Address base register
@item f
Floating point register
+@item v
+Vector register
+
@item h
@samp{MQ}, @samp{CTR}, or @samp{LINK} register
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index d6568c9a01d..6b8ad5ecabe 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -7693,8 +7693,7 @@ defined, GCC uses @code{DBX_DEBUG}.
The value of this macro only affects the default debugging output; the
user can always get a specific type of output by using @option{-gstabs},
-@option{-gcoff}, @option{-gdwarf-1}, @option{-gdwarf-2}, @option{-gxcoff},
-or @option{-gvms}.
+@option{-gcoff}, @option{-gdwarf-2}, @option{-gxcoff}, or @option{-gvms}.
@end defmac
@node DBX Options
@@ -7970,11 +7969,6 @@ Define this macro if GCC should produce COFF-style debugging output
for SDB in response to the @option{-g} option.
@end defmac
-@defmac DWARF_DEBUGGING_INFO
-Define this macro if GCC should produce dwarf format debugging output
-in response to the @option{-g} option.
-@end defmac
-
@defmac DWARF2_DEBUGGING_INFO
Define this macro if GCC should produce dwarf version 2 format
debugging output in response to the @option{-g} option.
diff --git a/gcc/dominance.c b/gcc/dominance.c
index 38182ef5318..1b6c9fd8f42 100644
--- a/gcc/dominance.c
+++ b/gcc/dominance.c
@@ -43,16 +43,8 @@
#include "errors.h"
#include "et-forest.h"
-struct dominance_info
-{
- et_forest_t forest;
- varray_type varray;
-};
-
-#define BB_NODE(info, bb) \
- ((et_forest_node_t)VARRAY_GENERIC_PTR ((info)->varray, (bb)->index + 2))
-#define SET_BB_NODE(info, bb, node) \
- (VARRAY_GENERIC_PTR ((info)->varray, (bb)->index + 2) = (node))
+/* Whether the dominators and the postdominators are available. */
+enum dom_state dom_computed[2];
/* We name our nodes with integers, beginning with 1. Zero is reserved for
'undefined' or 'end of list'. The name of each node is given by the dfs
@@ -124,7 +116,7 @@ static void compress (struct dom_info *, TBB);
static TBB eval (struct dom_info *, TBB);
static void link_roots (struct dom_info *, TBB, TBB);
static void calc_idoms (struct dom_info *, enum cdi_direction);
-void debug_dominance_info (dominance_info);
+void debug_dominance_info (enum cdi_direction);
/* Helper macro for allocating and initializing an array,
for aesthetic reasons. */
@@ -526,172 +518,250 @@ calc_idoms (struct dom_info *di, enum cdi_direction reverse)
di->dom[v] = di->dom[di->dom[v]];
}
-/* The main entry point into this module. IDOM is an integer array with room
- for last_basic_block integers, DOMS is a preallocated sbitmap array having
- room for last_basic_block^2 bits, and POST is true if the caller wants to
- know post-dominators.
+/* Assign dfs numbers starting from NUM to NODE and its sons. */
+
+static void
+assign_dfs_numbers (struct et_node *node, int *num)
+{
+ struct et_node *son;
+
+ node->dfs_num_in = (*num)++;
+
+ if (node->son)
+ {
+ assign_dfs_numbers (node->son, num);
+ for (son = node->son->right; son != node->son; son = son->right)
+ assign_dfs_numbers (son, num);
+ }
- On return IDOM[i] will be the BB->index of the immediate (post) dominator
- of basic block i, and DOMS[i] will have set bit j if basic block j is a
- (post)dominator for block i.
+ node->dfs_num_out = (*num)++;
+}
- Either IDOM or DOMS may be NULL (meaning the caller is not interested in
- immediate resp. all dominators). */
+/* Compute the data neccesary for fast resolving of dominator queries in a
+ static dominator tree. */
-dominance_info
-calculate_dominance_info (enum cdi_direction reverse)
+static void
+compute_dom_fast_query (enum cdi_direction dir)
+{
+ int num = 0;
+ basic_block bb;
+
+ if (dom_computed[dir] < DOM_NO_FAST_QUERY)
+ abort ();
+
+ if (dom_computed[dir] == DOM_OK)
+ return;
+
+ FOR_ALL_BB (bb)
+ {
+ if (!bb->dom[dir]->father)
+ assign_dfs_numbers (bb->dom[dir], &num);
+ }
+
+ dom_computed[dir] = DOM_OK;
+}
+
+/* The main entry point into this module. DIR is set depending on whether
+ we want to compute dominators or postdominators. */
+
+void
+calculate_dominance_info (enum cdi_direction dir)
{
struct dom_info di;
- dominance_info info;
basic_block b;
- /* Allocate structure for dominance information. */
- info = xmalloc (sizeof (struct dominance_info));
- info->forest = et_forest_create ();
- VARRAY_GENERIC_PTR_INIT (info->varray, last_basic_block + 3, "dominance info");
+ if (dom_computed[dir] == DOM_OK)
+ return;
- /* Add the two well-known basic blocks. */
- SET_BB_NODE (info, ENTRY_BLOCK_PTR, et_forest_add_node (info->forest,
- ENTRY_BLOCK_PTR));
- SET_BB_NODE (info, EXIT_BLOCK_PTR, et_forest_add_node (info->forest,
- EXIT_BLOCK_PTR));
- FOR_EACH_BB (b)
- SET_BB_NODE (info, b, et_forest_add_node (info->forest, b));
+ if (dom_computed[dir] != DOM_NO_FAST_QUERY)
+ {
+ if (dom_computed[dir] != DOM_NONE)
+ free_dominance_info (dir);
- init_dom_info (&di);
- calc_dfs_tree (&di, reverse);
- calc_idoms (&di, reverse);
+ FOR_ALL_BB (b)
+ {
+ b->dom[dir] = et_new_tree (b);
+ }
+ init_dom_info (&di);
+ calc_dfs_tree (&di, dir);
+ calc_idoms (&di, dir);
- FOR_EACH_BB (b)
- {
- TBB d = di.dom[di.dfs_order[b->index]];
+ FOR_EACH_BB (b)
+ {
+ TBB d = di.dom[di.dfs_order[b->index]];
+
+ if (di.dfs_to_bb[d])
+ et_set_father (b->dom[dir], di.dfs_to_bb[d]->dom[dir]);
+ }
- if (di.dfs_to_bb[d])
- et_forest_add_edge (info->forest, BB_NODE (info, di.dfs_to_bb[d]), BB_NODE (info, b));
+ free_dom_info (&di);
+ dom_computed[dir] = DOM_NO_FAST_QUERY;
}
- free_dom_info (&di);
- return info;
+ compute_dom_fast_query (dir);
}
-/* Free dominance information. */
+/* Free dominance information for direction DIR. */
void
-free_dominance_info (dominance_info info)
+free_dominance_info (enum cdi_direction dir)
{
basic_block bb;
- /* Allow users to create new basic block without setting up the dominance
- information for them. */
- FOR_EACH_BB (bb)
- if (bb->index < (int)(info->varray->num_elements - 2)
- && BB_NODE (info, bb))
- delete_from_dominance_info (info, bb);
- delete_from_dominance_info (info, ENTRY_BLOCK_PTR);
- delete_from_dominance_info (info, EXIT_BLOCK_PTR);
- et_forest_delete (info->forest);
- VARRAY_GROW (info->varray, 0);
- free (info);
+ if (!dom_computed[dir])
+ return;
+
+ FOR_ALL_BB (bb)
+ {
+ delete_from_dominance_info (dir, bb);
+ }
+
+ dom_computed[dir] = DOM_NONE;
}
/* Return the immediate dominator of basic block BB. */
basic_block
-get_immediate_dominator (dominance_info dom, basic_block bb)
+get_immediate_dominator (enum cdi_direction dir, basic_block bb)
{
- return et_forest_node_value (dom->forest,
- et_forest_parent (dom->forest,
- BB_NODE (dom, bb)));
+ struct et_node *node = bb->dom[dir];
+
+ if (!dom_computed[dir])
+ abort ();
+
+ if (!node->father)
+ return NULL;
+
+ return node->father->data;
}
/* Set the immediate dominator of the block possibly removing
existing edge. NULL can be used to remove any edge. */
inline void
-set_immediate_dominator (dominance_info dom, basic_block bb, basic_block dominated_by)
+set_immediate_dominator (enum cdi_direction dir, basic_block bb,
+ basic_block dominated_by)
{
- void *aux_bb_node;
- et_forest_node_t bb_node = BB_NODE (dom, bb);
+ struct et_node *node = bb->dom[dir];
+
+ if (!dom_computed[dir])
+ abort ();
- aux_bb_node = et_forest_parent (dom->forest, bb_node);
- if (aux_bb_node)
- et_forest_remove_edge (dom->forest, aux_bb_node, bb_node);
- if (dominated_by != NULL)
+ if (node->father)
{
- if (bb == dominated_by)
- abort ();
- if (!et_forest_add_edge (dom->forest, BB_NODE (dom, dominated_by), bb_node))
- abort ();
+ if (node->father->data == dominated_by)
+ return;
+ et_split (node);
}
+
+ if (dominated_by)
+ et_set_father (node, dominated_by->dom[dir]);
+
+ if (dom_computed[dir] == DOM_OK)
+ dom_computed[dir] = DOM_NO_FAST_QUERY;
}
-/* Store all basic blocks dominated by BB into BBS and return their number. */
+/* Store all basic blocks immediatelly dominated by BB into BBS and return
+ their number. */
int
-get_dominated_by (dominance_info dom, basic_block bb, basic_block **bbs)
+get_dominated_by (enum cdi_direction dir, basic_block bb, basic_block **bbs)
{
- int n, i;
+ int n;
+ struct et_node *node = bb->dom[dir], *son = node->son, *ason;
+
+ if (!dom_computed[dir])
+ abort ();
+
+ if (!son)
+ {
+ *bbs = NULL;
+ return 0;
+ }
+
+ for (ason = son->right, n = 1; ason != son; ason = ason->right)
+ n++;
+
+ *bbs = xmalloc (n * sizeof (basic_block));
+ (*bbs)[0] = son->data;
+ for (ason = son->right, n = 1; ason != son; ason = ason->right)
+ (*bbs)[n++] = ason->data;
- *bbs = xmalloc (n_basic_blocks * sizeof (basic_block));
- n = et_forest_enumerate_sons (dom->forest, BB_NODE (dom, bb), (et_forest_node_t *)*bbs);
- for (i = 0; i < n; i++)
- (*bbs)[i] = et_forest_node_value (dom->forest, (et_forest_node_t)(*bbs)[i]);
return n;
}
/* Redirect all edges pointing to BB to TO. */
void
-redirect_immediate_dominators (dominance_info dom, basic_block bb, basic_block to)
+redirect_immediate_dominators (enum cdi_direction dir, basic_block bb,
+ basic_block to)
{
- et_forest_node_t *bbs = xmalloc (n_basic_blocks * sizeof (basic_block));
- et_forest_node_t node = BB_NODE (dom, bb);
- et_forest_node_t node2 = BB_NODE (dom, to);
- int n = et_forest_enumerate_sons (dom->forest, node, bbs);
- int i;
+ struct et_node *bb_node = bb->dom[dir], *to_node = to->dom[dir], *son;
+
+ if (!dom_computed[dir])
+ abort ();
- for (i = 0; i < n; i++)
+ if (!bb_node->son)
+ return;
+
+ while (bb_node->son)
{
- et_forest_remove_edge (dom->forest, node, bbs[i]);
- et_forest_add_edge (dom->forest, node2, bbs[i]);
+ son = bb_node->son;
+
+ et_split (son);
+ et_set_father (son, to_node);
}
- free (bbs);
+
+ if (dom_computed[dir] == DOM_OK)
+ dom_computed[dir] = DOM_NO_FAST_QUERY;
}
/* Find first basic block in the tree dominating both BB1 and BB2. */
basic_block
-nearest_common_dominator (dominance_info dom, basic_block bb1, basic_block bb2)
+nearest_common_dominator (enum cdi_direction dir, basic_block bb1, basic_block bb2)
{
+ if (!dom_computed[dir])
+ abort ();
+
if (!bb1)
return bb2;
if (!bb2)
return bb1;
- return et_forest_node_value (dom->forest,
- et_forest_common_ancestor (dom->forest,
- BB_NODE (dom, bb1),
- BB_NODE (dom,
- bb2)));
+
+ return et_nca (bb1->dom[dir], bb2->dom[dir])->data;
}
/* Return TRUE in case BB1 is dominated by BB2. */
bool
-dominated_by_p (dominance_info dom, basic_block bb1, basic_block bb2)
+dominated_by_p (enum cdi_direction dir, basic_block bb1, basic_block bb2)
{
- return nearest_common_dominator (dom, bb1, bb2) == bb2;
+ struct et_node *n1 = bb1->dom[dir], *n2 = bb2->dom[dir];
+
+ if (!dom_computed[dir])
+ abort ();
+
+ if (dom_computed[dir] == DOM_OK)
+ return (n1->dfs_num_in >= n2->dfs_num_in
+ && n1->dfs_num_out <= n2->dfs_num_out);
+
+ return et_below (n1, n2);
}
/* Verify invariants of dominator structure. */
void
-verify_dominators (dominance_info dom)
+verify_dominators (enum cdi_direction dir)
{
int err = 0;
basic_block bb;
+ if (!dom_computed[dir])
+ abort ();
+
FOR_EACH_BB (bb)
{
basic_block dom_bb;
- dom_bb = recount_dominator (dom, bb);
- if (dom_bb != get_immediate_dominator (dom, bb))
+ dom_bb = recount_dominator (dir, bb);
+ if (dom_bb != get_immediate_dominator (dir, bb))
{
error ("dominator of %d should be %d, not %d",
- bb->index, dom_bb->index, get_immediate_dominator(dom, bb)->index);
+ bb->index, dom_bb->index, get_immediate_dominator(dir, bb)->index);
err = 1;
}
}
@@ -701,15 +771,18 @@ verify_dominators (dominance_info dom)
/* Recount dominator of BB. */
basic_block
-recount_dominator (dominance_info dom, basic_block bb)
+recount_dominator (enum cdi_direction dir, basic_block bb)
{
basic_block dom_bb = NULL;
edge e;
+ if (!dom_computed[dir])
+ abort ();
+
for (e = bb->pred; e; e = e->pred_next)
{
- if (!dominated_by_p (dom, e->src, bb))
- dom_bb = nearest_common_dominator (dom, dom_bb, e->src);
+ if (!dominated_by_p (dir, e->src, bb))
+ dom_bb = nearest_common_dominator (dir, dom_bb, e->src);
}
return dom_bb;
@@ -718,50 +791,85 @@ recount_dominator (dominance_info dom, basic_block bb)
/* Iteratively recount dominators of BBS. The change is supposed to be local
and not to grow further. */
void
-iterate_fix_dominators (dominance_info dom, basic_block *bbs, int n)
+iterate_fix_dominators (enum cdi_direction dir, basic_block *bbs, int n)
{
int i, changed = 1;
basic_block old_dom, new_dom;
+ if (!dom_computed[dir])
+ abort ();
+
while (changed)
{
changed = 0;
for (i = 0; i < n; i++)
{
- old_dom = get_immediate_dominator (dom, bbs[i]);
- new_dom = recount_dominator (dom, bbs[i]);
+ old_dom = get_immediate_dominator (dir, bbs[i]);
+ new_dom = recount_dominator (dir, bbs[i]);
if (old_dom != new_dom)
{
changed = 1;
- set_immediate_dominator (dom, bbs[i], new_dom);
+ set_immediate_dominator (dir, bbs[i], new_dom);
}
}
}
}
void
-add_to_dominance_info (dominance_info dom, basic_block bb)
+add_to_dominance_info (enum cdi_direction dir, basic_block bb)
{
- VARRAY_GROW (dom->varray, last_basic_block + 3);
-#ifdef ENABLE_CHECKING
- if (BB_NODE (dom, bb))
+ if (!dom_computed[dir])
abort ();
-#endif
- SET_BB_NODE (dom, bb, et_forest_add_node (dom->forest, bb));
+
+ if (bb->dom[dir])
+ abort ();
+
+ bb->dom[dir] = et_new_tree (bb);
+
+ if (dom_computed[dir] == DOM_OK)
+ dom_computed[dir] = DOM_NO_FAST_QUERY;
}
void
-delete_from_dominance_info (dominance_info dom, basic_block bb)
+delete_from_dominance_info (enum cdi_direction dir, basic_block bb)
+{
+ if (!dom_computed[dir])
+ abort ();
+
+ et_free_tree (bb->dom[dir]);
+ bb->dom[dir] = NULL;
+
+ if (dom_computed[dir] == DOM_OK)
+ dom_computed[dir] = DOM_NO_FAST_QUERY;
+}
+
+/* Returns the first son of BB in the dominator or postdominator tree
+ as determined by DIR. */
+
+basic_block
+first_dom_son (enum cdi_direction dir, basic_block bb)
{
- et_forest_remove_node (dom->forest, BB_NODE (dom, bb));
- SET_BB_NODE (dom, bb, NULL);
+ struct et_node *son = bb->dom[dir]->son;
+
+ return son ? son->data : NULL;
+}
+
+/* Returns the next dominance son after BB in the dominator or postdominator
+ tree as determined by DIR, or NULL if it was the last one. */
+
+basic_block
+next_dom_son (enum cdi_direction dir, basic_block bb)
+{
+ struct et_node *next = bb->dom[dir]->right;
+
+ return next->father->son == next ? NULL : next->data;
}
void
-debug_dominance_info (dominance_info dom)
+debug_dominance_info (enum cdi_direction dir)
{
basic_block bb, bb2;
FOR_EACH_BB (bb)
- if ((bb2 = get_immediate_dominator (dom, bb)))
+ if ((bb2 = get_immediate_dominator (dir, bb)))
fprintf (stderr, "%i %i\n", bb->index, bb2->index);
}
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 8ecc5d1b5f1..b765aefdc94 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3872,7 +3872,7 @@ static int maybe_emit_file (int);
/* Definitions of defaults for formats and names of various special
(artificial) labels which may be generated within this file (when the -g
- options is used and DWARF_DEBUGGING_INFO is in effect.
+ options is used and DWARF2_DEBUGGING_INFO is in effect.
If necessary, these may be overridden from within the tm.h file, but
typically, overriding these defaults is unnecessary. */
diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c
deleted file mode 100644
index b90bb6bd7fa..00000000000
--- a/gcc/dwarfout.c
+++ /dev/null
@@ -1,6396 +0,0 @@
-/* Output Dwarf format symbol table information from GCC.
- Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003 Free Software Foundation, Inc.
- Contributed by Ron Guilmette (rfg@monkeys.com) of Network Computing Devices.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
-
-/*
-
- Notes on the GNU Implementation of DWARF Debugging Information
- --------------------------------------------------------------
- Last Major Update: Sun Jul 17 08:17:42 PDT 1994 by rfg@segfault.us.com
- ------------------------------------------------------------
-
- This file describes special and unique aspects of the GNU implementation of
- the DWARF Version 1 debugging information language, as provided in the GNU
- version 2.x compiler(s).
-
- For general information about the DWARF debugging information language,
- you should obtain the DWARF version 1.1 specification document (and perhaps
- also the DWARF version 2 draft specification document) developed by the
- (now defunct) UNIX International Programming Languages Special Interest Group.
-
- To obtain a copy of the DWARF Version 1 and/or DWARF Version 2
- specification, visit the web page for the DWARF Version 2 committee, at
-
- http://www.eagercon.com/dwarf/dwarf2std.htm
-
- The generation of DWARF debugging information by the GNU version 2.x C
- compiler has now been tested rather extensively for m88k, i386, i860, and
- SPARC targets. The DWARF output of the GNU C compiler appears to inter-
- operate well with the standard SVR4 SDB debugger on these kinds of target
- systems (but of course, there are no guarantees).
-
- DWARF 1 generation for the GNU g++ compiler is implemented, but limited.
- C++ users should definitely use DWARF 2 instead.
-
- Future plans for the dwarfout.c module of the GNU compiler(s) includes the
- addition of full support for GNU FORTRAN. (This should, in theory, be a
- lot simpler to add than adding support for g++... but we'll see.)
-
- Many features of the DWARF version 2 specification have been adapted to
- (and used in) the GNU implementation of DWARF (version 1). In most of
- these cases, a DWARF version 2 approach is used in place of (or in addition
- to) DWARF version 1 stuff simply because it is apparent that DWARF version
- 1 is not sufficiently expressive to provide the kinds of information which
- may be necessary to support really robust debugging. In all of these cases
- however, the use of DWARF version 2 features should not interfere in any
- way with the interoperability (of GNU compilers) with generally available
- "classic" (pre version 1) DWARF consumer tools (e.g. SVR4 SDB).
-
- The DWARF generation enhancement for the GNU compiler(s) was initially
- donated to the Free Software Foundation by Network Computing Devices.
- (Thanks NCD!) Additional development and maintenance of dwarfout.c has
- been largely supported (i.e. funded) by Intel Corporation. (Thanks Intel!)
-
- If you have questions or comments about the DWARF generation feature, please
- send mail to me <rfg@netcom.com>. I will be happy to investigate any bugs
- reported and I may even provide fixes (but of course, I can make no promises).
-
- The DWARF debugging information produced by GCC may deviate in a few minor
- (but perhaps significant) respects from the DWARF debugging information
- currently produced by other C compilers. A serious attempt has been made
- however to conform to the published specifications, to existing practice,
- and to generally accepted norms in the GNU implementation of DWARF.
-
- ** IMPORTANT NOTE ** ** IMPORTANT NOTE ** ** IMPORTANT NOTE **
-
- Under normal circumstances, the DWARF information generated by the GNU
- compilers (in an assembly language file) is essentially impossible for
- a human being to read. This fact can make it very difficult to debug
- certain DWARF-related problems. In order to overcome this difficulty,
- a feature has been added to dwarfout.c (enabled by the -dA
- option) which causes additional comments to be placed into the assembly
- language output file, out to the right-hand side of most bits of DWARF
- material. The comments indicate (far more clearly that the obscure
- DWARF hex codes do) what is actually being encoded in DWARF. Thus, the
- -dA option can be highly useful for those who must study the
- DWARF output from the GNU compilers in detail.
-
- ---------
-
- (Footnote: Within this file, the term `Debugging Information Entry' will
- be abbreviated as `DIE'.)
-
-
- Release Notes (aka known bugs)
- -------------------------------
-
- In one very obscure case involving dynamically sized arrays, the DWARF
- "location information" for such an array may make it appear that the
- array has been totally optimized out of existence, when in fact it
- *must* actually exist. (This only happens when you are using *both* -g
- *and* -O.) This is due to aggressive dead store elimination in the
- compiler, and to the fact that the DECL_RTL expressions associated with
- variables are not always updated to correctly reflect the effects of
- GCC's aggressive dead store elimination.
-
- -------------------------------
-
- When attempting to set a breakpoint at the "start" of a function compiled
- with -g1, the debugger currently has no way of knowing exactly where the
- end of the prologue code for the function is. Thus, for most targets,
- all the debugger can do is to set the breakpoint at the AT_low_pc address
- for the function. But if you stop there and then try to look at one or
- more of the formal parameter values, they may not have been "homed" yet,
- so you may get inaccurate answers (or perhaps even addressing errors).
-
- Some people may consider this simply a non-feature, but I consider it a
- bug, and I hope to provide some GNU-specific attributes (on function
- DIEs) which will specify the address of the end of the prologue and the
- address of the beginning of the epilogue in a future release.
-
- -------------------------------
-
- It is believed at this time that old bugs relating to the AT_bit_offset
- values for bit-fields have been fixed.
-
- There may still be some very obscure bugs relating to the DWARF description
- of type `long long' bit-fields for target machines (e.g. 80x86 machines)
- where the alignment of type `long long' data objects is different from
- (and less than) the size of a type `long long' data object.
-
- Please report any problems with the DWARF description of bit-fields as you
- would any other GCC bug. (Procedures for bug reporting are given in the
- GNU C compiler manual.)
-
- --------------------------------
-
- At this time, GCC does not know how to handle the GNU C "nested functions"
- extension. (See the GCC manual for more info on this extension to ANSI C.)
-
- --------------------------------
-
- The GNU compilers now represent inline functions (and inlined instances
- thereof) in exactly the manner described by the current DWARF version 2
- (draft) specification. The version 1 specification for handling inline
- functions (and inlined instances) was known to be brain-damaged (by the
- PLSIG) when the version 1 spec was finalized, but it was simply too late
- in the cycle to get it removed before the version 1 spec was formally
- released to the public (by UI).
-
- --------------------------------
-
- At this time, GCC does not generate the kind of really precise information
- about the exact declared types of entities with signed integral types which
- is required by the current DWARF draft specification.
-
- Specifically, the current DWARF draft specification seems to require that
- the type of a non-unsigned integral bit-field member of a struct or union
- type be represented as either a "signed" type or as a "plain" type,
- depending upon the exact set of keywords that were used in the
- type specification for the given bit-field member. It was felt (by the
- UI/PLSIG) that this distinction between "plain" and "signed" integral types
- could have some significance (in the case of bit-fields) because ANSI C
- does not constrain the signedness of a plain bit-field, whereas it does
- constrain the signedness of an explicitly "signed" bit-field. For this
- reason, the current DWARF specification calls for compilers to produce
- type information (for *all* integral typed entities... not just bit-fields)
- which explicitly indicates the signedness of the relevant type to be
- "signed" or "plain" or "unsigned".
-
- Unfortunately, the GNU DWARF implementation is currently incapable of making
- such distinctions.
-
- --------------------------------
-
-
- Known Interoperability Problems
- -------------------------------
-
- Although the GNU implementation of DWARF conforms (for the most part) with
- the current UI/PLSIG DWARF version 1 specification (with many compatible
- version 2 features added in as "vendor specific extensions" just for good
- measure) there are a few known cases where GCC's DWARF output can cause
- some confusion for "classic" (pre version 1) DWARF consumers such as the
- System V Release 4 SDB debugger. These cases are described in this section.
-
- --------------------------------
-
- The DWARF version 1 specification includes the fundamental type codes
- FT_ext_prec_float, FT_complex, FT_dbl_prec_complex, and FT_ext_prec_complex.
- Since GNU C is only a C compiler (and since C doesn't provide any "complex"
- data types) the only one of these fundamental type codes which GCC ever
- generates is FT_ext_prec_float. This fundamental type code is generated
- by GCC for the `long double' data type. Unfortunately, due to an apparent
- bug in the SVR4 SDB debugger, SDB can become very confused wherever any
- attempt is made to print a variable, parameter, or field whose type was
- given in terms of FT_ext_prec_float.
-
- (Actually, SVR4 SDB fails to understand *any* of the four fundamental type
- codes mentioned here. This will fact will cause additional problems when
- there is a GNU FORTRAN front-end.)
-
- --------------------------------
-
- In general, it appears that SVR4 SDB is not able to effectively ignore
- fundamental type codes in the "implementation defined" range. This can
- cause problems when a program being debugged uses the `long long' data
- type (or the signed or unsigned varieties thereof) because these types
- are not defined by ANSI C, and thus, GCC must use its own private fundamental
- type codes (from the implementation-defined range) to represent these types.
-
- --------------------------------
-
-
- General GNU DWARF extensions
- ----------------------------
-
- In the current DWARF version 1 specification, no mechanism is specified by
- which accurate information about executable code from include files can be
- properly (and fully) described. (The DWARF version 2 specification *does*
- specify such a mechanism, but it is about 10 times more complicated than
- it needs to be so I'm not terribly anxious to try to implement it right
- away.)
-
- In the GNU implementation of DWARF version 1, a fully downward-compatible
- extension has been implemented which permits the GNU compilers to specify
- which executable lines come from which files. This extension places
- additional information (about source file names) in GNU-specific sections
- (which should be totally ignored by all non-GNU DWARF consumers) so that
- this extended information can be provided (to GNU DWARF consumers) in a way
- which is totally transparent (and invisible) to non-GNU DWARF consumers
- (e.g. the SVR4 SDB debugger). The additional information is placed *only*
- in specialized GNU-specific sections, where it should never even be seen
- by non-GNU DWARF consumers.
-
- To understand this GNU DWARF extension, imagine that the sequence of entries
- in the .lines section is broken up into several subsections. Each contiguous
- sequence of .line entries which relates to a sequence of lines (or statements)
- from one particular file (either a `base' file or an `include' file) could
- be called a `line entries chunk' (LEC).
-
- For each LEC there is one entry in the .debug_srcinfo section.
-
- Each normal entry in the .debug_srcinfo section consists of two 4-byte
- words of data as follows:
-
- (1) The starting address (relative to the entire .line section)
- of the first .line entry in the relevant LEC.
-
- (2) The starting address (relative to the entire .debug_sfnames
- section) of a NUL terminated string representing the
- relevant filename. (This filename name be either a
- relative or an absolute filename, depending upon how the
- given source file was located during compilation.)
-
- Obviously, each .debug_srcinfo entry allows you to find the relevant filename,
- and it also points you to the first .line entry that was generated as a result
- of having compiled a given source line from the given source file.
-
- Each subsequent .line entry should also be assumed to have been produced
- as a result of compiling yet more lines from the same file. The end of
- any given LEC is easily found by looking at the first 4-byte pointer in
- the *next* .debug_srcinfo entry. That next .debug_srcinfo entry points
- to a new and different LEC, so the preceding LEC (implicitly) must have
- ended with the last .line section entry which occurs at the 2 1/2 words
- just before the address given in the first pointer of the new .debug_srcinfo
- entry.
-
- The following picture may help to clarify this feature. Let's assume that
- `LE' stands for `.line entry'. Also, assume that `* 'stands for a pointer.
-
-
- .line section .debug_srcinfo section .debug_sfnames section
- ----------------------------------------------------------------
-
- LE <---------------------- *
- LE * -----------------> "foobar.c" <---
- LE |
- LE |
- LE <---------------------- * |
- LE * -----------------> "foobar.h" <| |
- LE | |
- LE | |
- LE <---------------------- * | |
- LE * -----------------> "inner.h" | |
- LE | |
- LE <---------------------- * | |
- LE * ------------------------------- |
- LE |
- LE |
- LE |
- LE |
- LE <---------------------- * |
- LE * -----------------------------------
- LE
- LE
- LE
-
- In effect, each entry in the .debug_srcinfo section points to *both* a
- filename (in the .debug_sfnames section) and to the start of a block of
- consecutive LEs (in the .line section).
-
- Note that just like in the .line section, there are specialized first and
- last entries in the .debug_srcinfo section for each object file. These
- special first and last entries for the .debug_srcinfo section are very
- different from the normal .debug_srcinfo section entries. They provide
- additional information which may be helpful to a debugger when it is
- interpreting the data in the .debug_srcinfo, .debug_sfnames, and .line
- sections.
-
- The first entry in the .debug_srcinfo section for each compilation unit
- consists of five 4-byte words of data. The contents of these five words
- should be interpreted (by debuggers) as follows:
-
- (1) The starting address (relative to the entire .line section)
- of the .line section for this compilation unit.
-
- (2) The starting address (relative to the entire .debug_sfnames
- section) of the .debug_sfnames section for this compilation
- unit.
-
- (3) The starting address (in the execution virtual address space)
- of the .text section for this compilation unit.
-
- (4) The ending address plus one (in the execution virtual address
- space) of the .text section for this compilation unit.
-
- (5) The date/time (in seconds since midnight 1/1/70) at which the
- compilation of this compilation unit occurred. This value
- should be interpreted as an unsigned quantity because gcc
- might be configured to generate a default value of 0xffffffff
- in this field (in cases where it is desired to have object
- files created at different times from identical source files
- be byte-for-byte identical). By default, these timestamps
- are *not* generated by dwarfout.c (so that object files
- compiled at different times will be byte-for-byte identical).
- If you wish to enable this "timestamp" feature however, you
- can simply place a #define for the symbol `DWARF_TIMESTAMPS'
- in your target configuration file and then rebuild the GNU
- compiler(s).
-
- Note that the first string placed into the .debug_sfnames section for each
- compilation unit is the name of the directory in which compilation occurred.
- This string ends with a `/' (to help indicate that it is the pathname of a
- directory). Thus, the second word of each specialized initial .debug_srcinfo
- entry for each compilation unit may be used as a pointer to the (string)
- name of the compilation directory, and that string may in turn be used to
- "absolutize" any relative pathnames which may appear later on in the
- .debug_sfnames section entries for the same compilation unit.
-
- The fifth and last word of each specialized starting entry for a compilation
- unit in the .debug_srcinfo section may (depending upon your configuration)
- indicate the date/time of compilation, and this may be used (by a debugger)
- to determine if any of the source files which contributed code to this
- compilation unit are newer than the object code for the compilation unit
- itself. If so, the debugger may wish to print an "out-of-date" warning
- about the compilation unit.
-
- The .debug_srcinfo section associated with each compilation will also have
- a specialized terminating entry. This terminating .debug_srcinfo section
- entry will consist of the following two 4-byte words of data:
-
- (1) The offset, measured from the start of the .line section to
- the beginning of the terminating entry for the .line section.
-
- (2) A word containing the value 0xffffffff.
-
- --------------------------------
-
- In the current DWARF version 1 specification, no mechanism is specified by
- which information about macro definitions and un-definitions may be provided
- to the DWARF consumer.
-
- The DWARF version 2 (draft) specification does specify such a mechanism.
- That specification was based on the GNU ("vendor specific extension")
- which provided some support for macro definitions and un-definitions,
- but the "official" DWARF version 2 (draft) specification mechanism for
- handling macros and the GNU implementation have diverged somewhat. I
- plan to update the GNU implementation to conform to the "official"
- DWARF version 2 (draft) specification as soon as I get time to do that.
-
- Note that in the GNU implementation, additional information about macro
- definitions and un-definitions is *only* provided when the -g3 level of
- debug-info production is selected. (The default level is -g2 and the
- plain old -g option is considered to be identical to -g2.)
-
- GCC records information about macro definitions and undefinitions primarily
- in a section called the .debug_macinfo section. Normal entries in the
- .debug_macinfo section consist of the following three parts:
-
- (1) A special "type" byte.
-
- (2) A 3-byte line-number/filename-offset field.
-
- (3) A NUL terminated string.
-
- The interpretation of the second and third parts is dependent upon the
- value of the leading (type) byte.
-
- The type byte may have one of four values depending upon the type of the
- .debug_macinfo entry which follows. The 1-byte MACINFO type codes presently
- used, and their meanings are as follows:
-
- MACINFO_start A base file or an include file starts here.
- MACINFO_resume The current base or include file ends here.
- MACINFO_define A #define directive occurs here.
- MACINFO_undef A #undef directive occur here.
-
- (Note that the MACINFO_... codes mentioned here are simply symbolic names
- for constants which are defined in the GNU dwarf.h file.)
-
- For MACINFO_define and MACINFO_undef entries, the second (3-byte) field
- contains the number of the source line (relative to the start of the current
- base source file or the current include files) when the #define or #undef
- directive appears. For a MACINFO_define entry, the following string field
- contains the name of the macro which is defined, followed by its definition.
- Note that the definition is always separated from the name of the macro
- by at least one whitespace character. For a MACINFO_undef entry, the
- string which follows the 3-byte line number field contains just the name
- of the macro which is being undef'ed.
-
- For a MACINFO_start entry, the 3-byte field following the type byte contains
- the offset, relative to the start of the .debug_sfnames section for the
- current compilation unit, of a string which names the new source file which
- is beginning its inclusion at this point. Following that 3-byte field,
- each MACINFO_start entry always contains a zero length NUL terminated
- string.
-
- For a MACINFO_resume entry, the 3-byte field following the type byte contains
- the line number WITHIN THE INCLUDING FILE at which the inclusion of the
- current file (whose inclusion ends here) was initiated. Following that
- 3-byte field, each MACINFO_resume entry always contains a zero length NUL
- terminated string.
-
- Each set of .debug_macinfo entries for each compilation unit is terminated
- by a special .debug_macinfo entry consisting of a 4-byte zero value followed
- by a single NUL byte.
-
- --------------------------------
-
- In the current DWARF draft specification, no provision is made for providing
- a separate level of (limited) debugging information necessary to support
- tracebacks (only) through fully-debugged code (e.g. code in system libraries).
-
- A proposal to define such a level was submitted (by me) to the UI/PLSIG.
- This proposal was rejected by the UI/PLSIG for inclusion into the DWARF
- version 1 specification for two reasons. First, it was felt (by the PLSIG)
- that the issues involved in supporting a "traceback only" subset of DWARF
- were not well understood. Second, and perhaps more importantly, the PLSIG
- is already having enough trouble agreeing on what it means to be "conforming"
- to the DWARF specification, and it was felt that trying to specify multiple
- different *levels* of conformance would only complicate our discussions of
- this already divisive issue. Nonetheless, the GNU implementation of DWARF
- provides an abbreviated "traceback only" level of debug-info production for
- use with fully-debugged "system library" code. This level should only be
- used for fully debugged system library code, and even then, it should only
- be used where there is a very strong need to conserve disk space. This
- abbreviated level of debug-info production can be used by specifying the
- -g1 option on the compilation command line.
-
- --------------------------------
-
- As mentioned above, the GNU implementation of DWARF currently uses the DWARF
- version 2 (draft) approach for inline functions (and inlined instances
- thereof). This is used in preference to the version 1 approach because
- (quite simply) the version 1 approach is highly brain-damaged and probably
- unworkable.
-
- --------------------------------
-
-
- GNU DWARF Representation of GNU C Extensions to ANSI C
- ------------------------------------------------------
-
- The file dwarfout.c has been designed and implemented so as to provide
- some reasonable DWARF representation for each and every declarative
- construct which is accepted by the GNU C compiler. Since the GNU C
- compiler accepts a superset of ANSI C, this means that there are some
- cases in which the DWARF information produced by GCC must take some
- liberties in improvising DWARF representations for declarations which
- are only valid in (extended) GNU C.
-
- In particular, GNU C provides at least three significant extensions to
- ANSI C when it comes to declarations. These are (1) inline functions,
- and (2) dynamic arrays, and (3) incomplete enum types. (See the GCC
- manual for more information on these GNU extensions to ANSI C.) When
- used, these GNU C extensions are represented (in the generated DWARF
- output of GCC) in the most natural and intuitively obvious ways.
-
- In the case of inline functions, the DWARF representation is exactly as
- called for in the DWARF version 2 (draft) specification for an identical
- function written in C++; i.e. we "reuse" the representation of inline
- functions which has been defined for C++ to support this GNU C extension.
-
- In the case of dynamic arrays, we use the most obvious representational
- mechanism available; i.e. an array type in which the upper bound of
- some dimension (usually the first and only dimension) is a variable
- rather than a constant. (See the DWARF version 1 specification for more
- details.)
-
- In the case of incomplete enum types, such types are represented simply
- as TAG_enumeration_type DIEs which DO NOT contain either AT_byte_size
- attributes or AT_element_list attributes.
-
- --------------------------------
-
-
- Future Directions
- -----------------
-
- The codes, formats, and other paraphernalia necessary to provide proper
- support for symbolic debugging for the C++ language are still being worked
- on by the UI/PLSIG. The vast majority of the additions to DWARF which will
- be needed to completely support C++ have already been hashed out and agreed
- upon, but a few small issues (e.g. anonymous unions, access declarations)
- are still being discussed. Also, we in the PLSIG are still discussing
- whether or not we need to do anything special for C++ templates. (At this
- time it is not yet clear whether we even need to do anything special for
- these.)
-
- With regard to FORTRAN, the UI/PLSIG has defined what is believed to be a
- complete and sufficient set of codes and rules for adequately representing
- all of FORTRAN 77, and most of Fortran 90 in DWARF. While some support for
- this has been implemented in dwarfout.c, further implementation and testing
- is needed.
-
- GNU DWARF support for other languages (i.e. Pascal and Modula) is a moot
- issue until there are GNU front-ends for these other languages.
-
- As currently defined, DWARF only describes a (binary) language which can
- be used to communicate symbolic debugging information from a compiler
- through an assembler and a linker, to a debugger. There is no clear
- specification of what processing should be (or must be) done by the
- assembler and/or the linker. Fortunately, the role of the assembler
- is easily inferred (by anyone knowledgeable about assemblers) just by
- looking at examples of assembly-level DWARF code. Sadly though, the
- allowable (or required) processing steps performed by a linker are
- harder to infer and (perhaps) even harder to agree upon. There are
- several forms of very useful `post-processing' steps which intelligent
- linkers *could* (in theory) perform on object files containing DWARF,
- but any and all such link-time transformations are currently both disallowed
- and unspecified.
-
- In particular, possible link-time transformations of DWARF code which could
- provide significant benefits include (but are not limited to):
-
- Commonization of duplicate DIEs obtained from multiple input
- (object) files.
-
- Cross-compilation type checking based upon DWARF type information
- for objects and functions.
-
- Other possible `compacting' transformations designed to save disk
- space and to reduce linker & debugger I/O activity.
-
-*/
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-
-#ifdef DWARF_DEBUGGING_INFO
-#include "dwarf.h"
-#include "tree.h"
-#include "flags.h"
-#include "function.h"
-#include "rtl.h"
-#include "hard-reg-set.h"
-#include "insn-config.h"
-#include "reload.h"
-#include "output.h"
-#include "dwarf2asm.h"
-#include "toplev.h"
-#include "tm_p.h"
-#include "debug.h"
-#include "target.h"
-#include "langhooks.h"
-
-/* NOTE: In the comments in this file, many references are made to
- so called "Debugging Information Entries". For the sake of brevity,
- this term is abbreviated to `DIE' throughout the remainder of this
- file. */
-
-/* Note that the implementation of C++ support herein is (as yet) unfinished.
- If you want to try to complete it, more power to you. */
-
-/* How to start an assembler comment. */
-#ifndef ASM_COMMENT_START
-#define ASM_COMMENT_START ";#"
-#endif
-
-/* Define a macro which returns nonzero for any tagged type which is
- used (directly or indirectly) in the specification of either some
- function's return type or some formal parameter of some function.
- We use this macro when we are operating in "terse" mode to help us
- know what tagged types have to be represented in Dwarf (even in
- terse mode) and which ones don't.
-
- A flag bit with this meaning really should be a part of the normal
- GCC ..._TYPE nodes, but at the moment, there is no such bit defined
- for these nodes. For now, we have to just fake it. It it safe for
- us to simply return zero for all complete tagged types (which will
- get forced out anyway if they were used in the specification of some
- formal or return type) and nonzero for all incomplete tagged types.
-*/
-
-#define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
-
-/* Define a macro which returns nonzero for a TYPE_DECL which was
- implicitly generated for a tagged type.
-
- Note that unlike the gcc front end (which generates a NULL named
- TYPE_DECL node for each complete tagged type, each array type, and
- each function type node created) the g++ front end generates a
- _named_ TYPE_DECL node for each tagged type node created.
- These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
- generate a DW_TAG_typedef DIE for them. */
-#define TYPE_DECL_IS_STUB(decl) \
- (DECL_NAME (decl) == NULL \
- || (DECL_ARTIFICIAL (decl) \
- && is_tagged_type (TREE_TYPE (decl)) \
- && decl == TYPE_STUB_DECL (TREE_TYPE (decl))))
-
-/* Maximum size (in bytes) of an artificially generated label. */
-
-#define MAX_ARTIFICIAL_LABEL_BYTES 30
-
-/* Structure to keep track of source filenames. */
-
-struct filename_entry {
- unsigned number;
- const char * name;
-};
-
-typedef struct filename_entry filename_entry;
-
-/* Pointer to an array of elements, each one having the structure above. */
-
-static filename_entry *filename_table;
-
-/* Total number of entries in the table (i.e. array) pointed to by
- `filename_table'. This is the *total* and includes both used and
- unused slots. */
-
-static unsigned ft_entries_allocated;
-
-/* Number of entries in the filename_table which are actually in use. */
-
-static unsigned ft_entries;
-
-/* Size (in elements) of increments by which we may expand the filename
- table. Actually, a single hunk of space of this size should be enough
- for most typical programs. */
-
-#define FT_ENTRIES_INCREMENT 64
-
-/* Local pointer to the name of the main input file. Initialized in
- dwarfout_init. */
-
-static const char *primary_filename;
-
-/* Counter to generate unique names for DIEs. */
-
-static unsigned next_unused_dienum = 1;
-
-/* Number of the DIE which is currently being generated. */
-
-static unsigned current_dienum;
-
-/* Number to use for the special "pubname" label on the next DIE which
- represents a function or data object defined in this compilation
- unit which has "extern" linkage. */
-
-static int next_pubname_number = 0;
-
-#define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
-
-/* Pointer to a dynamically allocated list of pre-reserved and still
- pending sibling DIE numbers. Note that this list will grow as needed. */
-
-static unsigned *pending_sibling_stack;
-
-/* Counter to keep track of the number of pre-reserved and still pending
- sibling DIE numbers. */
-
-static unsigned pending_siblings;
-
-/* The currently allocated size of the above list (expressed in number of
- list elements). */
-
-static unsigned pending_siblings_allocated;
-
-/* Size (in elements) of increments by which we may expand the pending
- sibling stack. Actually, a single hunk of space of this size should
- be enough for most typical programs. */
-
-#define PENDING_SIBLINGS_INCREMENT 64
-
-/* Nonzero if we are performing our file-scope finalization pass and if
- we should force out Dwarf descriptions of any and all file-scope
- tagged types which are still incomplete types. */
-
-static int finalizing = 0;
-
-/* A pointer to the base of a list of pending types which we haven't
- generated DIEs for yet, but which we will have to come back to
- later on. */
-
-static tree *pending_types_list;
-
-/* Number of elements currently allocated for the pending_types_list. */
-
-static unsigned pending_types_allocated;
-
-/* Number of elements of pending_types_list currently in use. */
-
-static unsigned pending_types;
-
-/* Size (in elements) of increments by which we may expand the pending
- types list. Actually, a single hunk of space of this size should
- be enough for most typical programs. */
-
-#define PENDING_TYPES_INCREMENT 64
-
-/* A pointer to the base of a list of incomplete types which might be
- completed at some later time. */
-
-static tree *incomplete_types_list;
-
-/* Number of elements currently allocated for the incomplete_types_list. */
-static unsigned incomplete_types_allocated;
-
-/* Number of elements of incomplete_types_list currently in use. */
-static unsigned incomplete_types;
-
-/* Size (in elements) of increments by which we may expand the incomplete
- types list. Actually, a single hunk of space of this size should
- be enough for most typical programs. */
-#define INCOMPLETE_TYPES_INCREMENT 64
-
-/* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
- This is used in a hack to help us get the DIEs describing types of
- formal parameters to come *after* all of the DIEs describing the formal
- parameters themselves. That's necessary in order to be compatible
- with what the brain-damaged svr4 SDB debugger requires. */
-
-static tree fake_containing_scope;
-
-/* A pointer to the ..._DECL node which we have most recently been working
- on. We keep this around just in case something about it looks screwy
- and we want to tell the user what the source coordinates for the actual
- declaration are. */
-
-static tree dwarf_last_decl;
-
-/* A flag indicating that we are emitting the member declarations of a
- class, so member functions and variables should not be entirely emitted.
- This is a kludge to avoid passing a second argument to output_*_die. */
-
-static int in_class;
-
-/* Forward declarations for functions defined in this file. */
-
-static void dwarfout_init (const char *);
-static void dwarfout_finish (const char *);
-static void dwarfout_define (unsigned int, const char *);
-static void dwarfout_undef (unsigned int, const char *);
-static void dwarfout_start_source_file (unsigned, const char *);
-static void dwarfout_start_source_file_check (unsigned, const char *);
-static void dwarfout_end_source_file (unsigned);
-static void dwarfout_end_source_file_check (unsigned);
-static void dwarfout_begin_block (unsigned, unsigned);
-static void dwarfout_end_block (unsigned, unsigned);
-static void dwarfout_end_epilogue (unsigned int, const char *);
-static void dwarfout_source_line (unsigned int, const char *);
-static void dwarfout_end_prologue (unsigned int, const char *);
-static void dwarfout_end_function (unsigned int);
-static void dwarfout_function_decl (tree);
-static void dwarfout_global_decl (tree);
-static void dwarfout_deferred_inline_function (tree);
-static void dwarfout_file_scope_decl (tree , int);
-static const char *dwarf_tag_name (unsigned);
-static const char *dwarf_attr_name (unsigned);
-static const char *dwarf_stack_op_name (unsigned);
-static const char *dwarf_typemod_name (unsigned);
-static const char *dwarf_fmt_byte_name (unsigned);
-static const char *dwarf_fund_type_name (unsigned);
-static tree decl_ultimate_origin (tree);
-static tree block_ultimate_origin (tree);
-static tree decl_class_context (tree);
-#if 0
-static void output_unsigned_leb128 (unsigned long);
-static void output_signed_leb128 (long);
-#endif
-static int fundamental_type_code (tree);
-static tree root_type_1 (tree, int);
-static tree root_type (tree);
-static void write_modifier_bytes_1 (tree, int, int, int);
-static void write_modifier_bytes (tree, int, int);
-static inline int type_is_fundamental (tree);
-static void equate_decl_number_to_die_number (tree);
-static inline void equate_type_number_to_die_number (tree);
-static void output_reg_number (rtx);
-static void output_mem_loc_descriptor (rtx);
-static void output_loc_descriptor (rtx);
-static void output_bound_representation (tree, unsigned, char);
-static void output_enumeral_list (tree);
-static inline HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
-static inline tree field_type (tree);
-static inline unsigned int simple_type_align_in_bits (tree);
-static inline unsigned HOST_WIDE_INT simple_type_size_in_bits (tree);
-static HOST_WIDE_INT field_byte_offset (tree);
-static inline void sibling_attribute (void);
-static void location_attribute (rtx);
-static void data_member_location_attribute (tree);
-static void const_value_attribute (rtx);
-static void location_or_const_value_attribute (tree);
-static inline void name_attribute (const char *);
-static inline void fund_type_attribute (unsigned);
-static void mod_fund_type_attribute (tree, int, int);
-static inline void user_def_type_attribute (tree);
-static void mod_u_d_type_attribute (tree, int, int);
-#ifdef USE_ORDERING_ATTRIBUTE
-static inline void ordering_attribute (unsigned);
-#endif /* defined(USE_ORDERING_ATTRIBUTE) */
-static void subscript_data_attribute (tree);
-static void byte_size_attribute (tree);
-static inline void bit_offset_attribute (tree);
-static inline void bit_size_attribute (tree);
-static inline void element_list_attribute (tree);
-static inline void stmt_list_attribute (const char *);
-static inline void low_pc_attribute (const char *);
-static inline void high_pc_attribute (const char *);
-static inline void body_begin_attribute (const char *);
-static inline void body_end_attribute (const char *);
-static inline void language_attribute (unsigned);
-static inline void member_attribute (tree);
-#if 0
-static inline void string_length_attribute (tree);
-#endif
-static inline void comp_dir_attribute (const char *);
-static inline void sf_names_attribute (const char *);
-static inline void src_info_attribute (const char *);
-static inline void mac_info_attribute (const char *);
-static inline void prototyped_attribute (tree);
-static inline void producer_attribute (const char *);
-static inline void inline_attribute (tree);
-static inline void containing_type_attribute (tree);
-static inline void abstract_origin_attribute (tree);
-#ifdef DWARF_DECL_COORDINATES
-static inline void src_coords_attribute (unsigned, unsigned);
-#endif /* defined(DWARF_DECL_COORDINATES) */
-static inline void pure_or_virtual_attribute (tree);
-static void name_and_src_coords_attributes (tree);
-static void type_attribute (tree, int, int);
-static const char *type_tag (tree);
-static inline void dienum_push (void);
-static inline void dienum_pop (void);
-static inline tree member_declared_type (tree);
-static const char *function_start_label (tree);
-static void output_array_type_die (void *);
-static void output_set_type_die (void *);
-#if 0
-static void output_entry_point_die (void *);
-#endif
-static void output_inlined_enumeration_type_die (void *);
-static void output_inlined_structure_type_die (void *);
-static void output_inlined_union_type_die (void *);
-static void output_enumeration_type_die (void *);
-static void output_formal_parameter_die (void *);
-static void output_global_subroutine_die (void *);
-static void output_global_variable_die (void *);
-static void output_label_die (void *);
-static void output_lexical_block_die (void *);
-static void output_inlined_subroutine_die (void *);
-static void output_local_variable_die (void *);
-static void output_member_die (void *);
-#if 0
-static void output_pointer_type_die (void *);
-static void output_reference_type_die (void *);
-#endif
-static void output_ptr_to_mbr_type_die (void *);
-static void output_compile_unit_die (void *);
-static void output_string_type_die (void *);
-static void output_inheritance_die (void *);
-static void output_structure_type_die (void *);
-static void output_local_subroutine_die (void *);
-static void output_subroutine_type_die (void *);
-static void output_typedef_die (void *);
-static void output_union_type_die (void *);
-static void output_unspecified_parameters_die (void *);
-static void output_padded_null_die (void *);
-static void output_die (void (*)(void *), void *);
-static void end_sibling_chain (void);
-static void output_formal_types (tree);
-static void pend_type (tree);
-static int type_ok_for_scope (tree, tree);
-static void output_pending_types_for_scope (tree);
-static void output_type (tree, tree);
-static void output_tagged_type_instantiation (tree);
-static void output_block (tree, int);
-static void output_decls_for_scope (tree, int);
-static void output_decl (tree, tree);
-static void shuffle_filename_entry (filename_entry *);
-static void generate_new_sfname_entry (void);
-static unsigned lookup_filename (const char *);
-static void generate_srcinfo_entry (unsigned, unsigned);
-static void generate_macinfo_entry (unsigned int, rtx, const char *);
-static int is_pseudo_reg (rtx);
-static tree type_main_variant (tree);
-static int is_tagged_type (tree);
-static int is_redundant_typedef (tree);
-static void add_incomplete_type (tree);
-static void retry_incomplete_types (void);
-
-/* Definitions of defaults for assembler-dependent names of various
- pseudo-ops and section names.
-
- Theses may be overridden in your tm.h file (if necessary) for your
- particular assembler. The default values provided here correspond to
- what is expected by "standard" AT&T System V.4 assemblers. */
-
-#ifndef FILE_ASM_OP
-#define FILE_ASM_OP "\t.file\t"
-#endif
-#ifndef SET_ASM_OP
-#define SET_ASM_OP "\t.set\t"
-#endif
-
-/* Pseudo-ops for pushing the current section onto the section stack (and
- simultaneously changing to a new section) and for popping back to the
- section we were in immediately before this one. Note that most svr4
- assemblers only maintain a one level stack... you can push all the
- sections you want, but you can only pop out one level. (The sparc
- svr4 assembler is an exception to this general rule.) That's
- OK because we only use at most one level of the section stack herein. */
-
-#ifndef PUSHSECTION_ASM_OP
-#define PUSHSECTION_ASM_OP "\t.section\t"
-#endif
-#ifndef POPSECTION_ASM_OP
-#define POPSECTION_ASM_OP "\t.previous"
-#endif
-
-/* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
- to print the PUSHSECTION_ASM_OP and the section name. The default here
- works for almost all svr4 assemblers, except for the sparc, where the
- section name must be enclosed in double quotes. (See sparcv4.h.) */
-
-#ifndef PUSHSECTION_FORMAT
-#define PUSHSECTION_FORMAT "%s%s\n"
-#endif
-
-#ifndef DEBUG_SECTION
-#define DEBUG_SECTION ".debug"
-#endif
-#ifndef LINE_SECTION
-#define LINE_SECTION ".line"
-#endif
-#ifndef DEBUG_SFNAMES_SECTION
-#define DEBUG_SFNAMES_SECTION ".debug_sfnames"
-#endif
-#ifndef DEBUG_SRCINFO_SECTION
-#define DEBUG_SRCINFO_SECTION ".debug_srcinfo"
-#endif
-#ifndef DEBUG_MACINFO_SECTION
-#define DEBUG_MACINFO_SECTION ".debug_macinfo"
-#endif
-#ifndef DEBUG_PUBNAMES_SECTION
-#define DEBUG_PUBNAMES_SECTION ".debug_pubnames"
-#endif
-#ifndef DEBUG_ARANGES_SECTION
-#define DEBUG_ARANGES_SECTION ".debug_aranges"
-#endif
-#ifndef TEXT_SECTION_NAME
-#define TEXT_SECTION_NAME ".text"
-#endif
-#ifndef DATA_SECTION_NAME
-#define DATA_SECTION_NAME ".data"
-#endif
-#ifndef DATA1_SECTION_NAME
-#define DATA1_SECTION_NAME ".data1"
-#endif
-#ifndef RODATA_SECTION_NAME
-#define RODATA_SECTION_NAME ".rodata"
-#endif
-#ifndef RODATA1_SECTION_NAME
-#define RODATA1_SECTION_NAME ".rodata1"
-#endif
-#ifndef BSS_SECTION_NAME
-#define BSS_SECTION_NAME ".bss"
-#endif
-
-/* Definitions of defaults for formats and names of various special
- (artificial) labels which may be generated within this file (when
- the -g options is used and DWARF_DEBUGGING_INFO is in effect.
-
- If necessary, these may be overridden from within your tm.h file,
- but typically, you should never need to override these.
-
- These labels have been hacked (temporarily) so that they all begin with
- a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
- stock m88k/svr4 assembler, both of which need to see .L at the start of
- a label in order to prevent that label from going into the linker symbol
- table). When I get time, I'll have to fix this the right way so that we
- will use ASM_GENERATE_INTERNAL_LABEL and (*targetm.asm_out.internal_label) herein,
- but that will require a rather massive set of changes. For the moment,
- the following definitions out to produce the right results for all svr4
- and svr3 assemblers. -- rfg
-*/
-
-#ifndef TEXT_BEGIN_LABEL
-#define TEXT_BEGIN_LABEL "*.L_text_b"
-#endif
-#ifndef TEXT_END_LABEL
-#define TEXT_END_LABEL "*.L_text_e"
-#endif
-
-#ifndef DATA_BEGIN_LABEL
-#define DATA_BEGIN_LABEL "*.L_data_b"
-#endif
-#ifndef DATA_END_LABEL
-#define DATA_END_LABEL "*.L_data_e"
-#endif
-
-#ifndef DATA1_BEGIN_LABEL
-#define DATA1_BEGIN_LABEL "*.L_data1_b"
-#endif
-#ifndef DATA1_END_LABEL
-#define DATA1_END_LABEL "*.L_data1_e"
-#endif
-
-#ifndef RODATA_BEGIN_LABEL
-#define RODATA_BEGIN_LABEL "*.L_rodata_b"
-#endif
-#ifndef RODATA_END_LABEL
-#define RODATA_END_LABEL "*.L_rodata_e"
-#endif
-
-#ifndef RODATA1_BEGIN_LABEL
-#define RODATA1_BEGIN_LABEL "*.L_rodata1_b"
-#endif
-#ifndef RODATA1_END_LABEL
-#define RODATA1_END_LABEL "*.L_rodata1_e"
-#endif
-
-#ifndef BSS_BEGIN_LABEL
-#define BSS_BEGIN_LABEL "*.L_bss_b"
-#endif
-#ifndef BSS_END_LABEL
-#define BSS_END_LABEL "*.L_bss_e"
-#endif
-
-#ifndef LINE_BEGIN_LABEL
-#define LINE_BEGIN_LABEL "*.L_line_b"
-#endif
-#ifndef LINE_LAST_ENTRY_LABEL
-#define LINE_LAST_ENTRY_LABEL "*.L_line_last"
-#endif
-#ifndef LINE_END_LABEL
-#define LINE_END_LABEL "*.L_line_e"
-#endif
-
-#ifndef DEBUG_BEGIN_LABEL
-#define DEBUG_BEGIN_LABEL "*.L_debug_b"
-#endif
-#ifndef SFNAMES_BEGIN_LABEL
-#define SFNAMES_BEGIN_LABEL "*.L_sfnames_b"
-#endif
-#ifndef SRCINFO_BEGIN_LABEL
-#define SRCINFO_BEGIN_LABEL "*.L_srcinfo_b"
-#endif
-#ifndef MACINFO_BEGIN_LABEL
-#define MACINFO_BEGIN_LABEL "*.L_macinfo_b"
-#endif
-
-#ifndef DEBUG_ARANGES_BEGIN_LABEL
-#define DEBUG_ARANGES_BEGIN_LABEL "*.L_debug_aranges_begin"
-#endif
-#ifndef DEBUG_ARANGES_END_LABEL
-#define DEBUG_ARANGES_END_LABEL "*.L_debug_aranges_end"
-#endif
-
-#ifndef DIE_BEGIN_LABEL_FMT
-#define DIE_BEGIN_LABEL_FMT "*.L_D%u"
-#endif
-#ifndef DIE_END_LABEL_FMT
-#define DIE_END_LABEL_FMT "*.L_D%u_e"
-#endif
-#ifndef PUB_DIE_LABEL_FMT
-#define PUB_DIE_LABEL_FMT "*.L_P%u"
-#endif
-#ifndef BLOCK_BEGIN_LABEL_FMT
-#define BLOCK_BEGIN_LABEL_FMT "*.L_B%u"
-#endif
-#ifndef BLOCK_END_LABEL_FMT
-#define BLOCK_END_LABEL_FMT "*.L_B%u_e"
-#endif
-#ifndef SS_BEGIN_LABEL_FMT
-#define SS_BEGIN_LABEL_FMT "*.L_s%u"
-#endif
-#ifndef SS_END_LABEL_FMT
-#define SS_END_LABEL_FMT "*.L_s%u_e"
-#endif
-#ifndef EE_BEGIN_LABEL_FMT
-#define EE_BEGIN_LABEL_FMT "*.L_e%u"
-#endif
-#ifndef EE_END_LABEL_FMT
-#define EE_END_LABEL_FMT "*.L_e%u_e"
-#endif
-#ifndef MT_BEGIN_LABEL_FMT
-#define MT_BEGIN_LABEL_FMT "*.L_t%u"
-#endif
-#ifndef MT_END_LABEL_FMT
-#define MT_END_LABEL_FMT "*.L_t%u_e"
-#endif
-#ifndef LOC_BEGIN_LABEL_FMT
-#define LOC_BEGIN_LABEL_FMT "*.L_l%u"
-#endif
-#ifndef LOC_END_LABEL_FMT
-#define LOC_END_LABEL_FMT "*.L_l%u_e"
-#endif
-#ifndef BOUND_BEGIN_LABEL_FMT
-#define BOUND_BEGIN_LABEL_FMT "*.L_b%u_%u_%c"
-#endif
-#ifndef BOUND_END_LABEL_FMT
-#define BOUND_END_LABEL_FMT "*.L_b%u_%u_%c_e"
-#endif
-#ifndef BODY_BEGIN_LABEL_FMT
-#define BODY_BEGIN_LABEL_FMT "*.L_b%u"
-#endif
-#ifndef BODY_END_LABEL_FMT
-#define BODY_END_LABEL_FMT "*.L_b%u_e"
-#endif
-#ifndef FUNC_END_LABEL_FMT
-#define FUNC_END_LABEL_FMT "*.L_f%u_e"
-#endif
-#ifndef TYPE_NAME_FMT
-#define TYPE_NAME_FMT "*.L_T%u"
-#endif
-#ifndef DECL_NAME_FMT
-#define DECL_NAME_FMT "*.L_E%u"
-#endif
-#ifndef LINE_CODE_LABEL_FMT
-#define LINE_CODE_LABEL_FMT "*.L_LC%u"
-#endif
-#ifndef SFNAMES_ENTRY_LABEL_FMT
-#define SFNAMES_ENTRY_LABEL_FMT "*.L_F%u"
-#endif
-#ifndef LINE_ENTRY_LABEL_FMT
-#define LINE_ENTRY_LABEL_FMT "*.L_LE%u"
-#endif
-
-/* Definitions of defaults for various types of primitive assembly language
- output operations.
-
- If necessary, these may be overridden from within your tm.h file,
- but typically, you shouldn't need to override these. */
-
-#ifndef ASM_OUTPUT_PUSH_SECTION
-#define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
- fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
-#endif
-
-#ifndef ASM_OUTPUT_POP_SECTION
-#define ASM_OUTPUT_POP_SECTION(FILE) \
- fprintf ((FILE), "%s\n", POPSECTION_ASM_OP)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DELTA2
-#define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
- dw2_asm_output_delta (2, LABEL1, LABEL2, NULL)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DELTA4
-#define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
- dw2_asm_output_delta (4, LABEL1, LABEL2, NULL)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_TAG
-#define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
- dw2_asm_output_data (2, TAG, "%s", dwarf_tag_name (TAG));
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
-#define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
- dw2_asm_output_data (2, ATTR, "%s", dwarf_attr_name (ATTR))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_STACK_OP
-#define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
- dw2_asm_output_data (1, OP, "%s", dwarf_stack_op_name (OP))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_FUND_TYPE
-#define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
- dw2_asm_output_data (2, FT, "%s", dwarf_fund_type_name (FT))
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_FMT_BYTE
-#define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
- dw2_asm_output_data (1, FMT, "%s", dwarf_fmt_byte_name (FMT));
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
-#define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
- dw2_asm_output_data (1, MOD, "%s", dwarf_typemod_name (MOD));
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ADDR
-#define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
- dw2_asm_output_addr (4, LABEL, NULL)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_ADDR_CONST
-#define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
- dw2_asm_output_addr_rtx (4, RTX, NULL)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_REF
-#define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
- dw2_asm_output_addr (4, LABEL, NULL)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA1
-#define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
- dw2_asm_output_data (1, VALUE, NULL)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA2
-#define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
- dw2_asm_output_data (2, VALUE, NULL)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA4
-#define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
- dw2_asm_output_data (4, VALUE, NULL)
-#endif
-
-#ifndef ASM_OUTPUT_DWARF_DATA8
-#define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
- dw2_asm_output_data (8, VALUE, NULL)
-#endif
-
-/* ASM_OUTPUT_DWARF_STRING is defined to output an ascii string, but to
- NOT issue a trailing newline. We define ASM_OUTPUT_DWARF_STRING_NEWLINE
- based on whether ASM_OUTPUT_DWARF_STRING is defined or not. If it is
- defined, we call it, then issue the line feed. If not, we supply a
- default definition of calling ASM_OUTPUT_ASCII */
-
-#ifndef ASM_OUTPUT_DWARF_STRING
-#define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
- ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
-#else
-#define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
- ASM_OUTPUT_DWARF_STRING (FILE,P), ASM_OUTPUT_DWARF_STRING (FILE,"\n")
-#endif
-
-
-/* The debug hooks structure. */
-const struct gcc_debug_hooks dwarf_debug_hooks =
-{
- dwarfout_init,
- dwarfout_finish,
- dwarfout_define,
- dwarfout_undef,
- dwarfout_start_source_file_check,
- dwarfout_end_source_file_check,
- dwarfout_begin_block,
- dwarfout_end_block,
- debug_true_tree, /* ignore_block */
- dwarfout_source_line, /* source_line */
- dwarfout_source_line, /* begin_prologue */
- dwarfout_end_prologue,
- dwarfout_end_epilogue,
- debug_nothing_tree, /* begin_function */
- dwarfout_end_function,
- dwarfout_function_decl,
- dwarfout_global_decl,
- dwarfout_deferred_inline_function,
- debug_nothing_tree, /* outlining_inline_function */
- debug_nothing_rtx, /* label */
- debug_nothing_int /* handle_pch */
-};
-
-/************************ general utility functions **************************/
-
-static inline int
-is_pseudo_reg (rtx rtl)
-{
- return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
- || ((GET_CODE (rtl) == SUBREG)
- && (REGNO (SUBREG_REG (rtl)) >= FIRST_PSEUDO_REGISTER)));
-}
-
-static inline tree
-type_main_variant (tree type)
-{
- type = TYPE_MAIN_VARIANT (type);
-
- /* There really should be only one main variant among any group of variants
- of a given type (and all of the MAIN_VARIANT values for all members of
- the group should point to that one type) but sometimes the C front-end
- messes this up for array types, so we work around that bug here. */
-
- if (TREE_CODE (type) == ARRAY_TYPE)
- {
- while (type != TYPE_MAIN_VARIANT (type))
- type = TYPE_MAIN_VARIANT (type);
- }
-
- return type;
-}
-
-/* Return nonzero if the given type node represents a tagged type. */
-
-static inline int
-is_tagged_type (tree type)
-{
- enum tree_code code = TREE_CODE (type);
-
- return (code == RECORD_TYPE || code == UNION_TYPE
- || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
-}
-
-static const char *
-dwarf_tag_name (unsigned int tag)
-{
- switch (tag)
- {
- case TAG_padding: return "TAG_padding";
- case TAG_array_type: return "TAG_array_type";
- case TAG_class_type: return "TAG_class_type";
- case TAG_entry_point: return "TAG_entry_point";
- case TAG_enumeration_type: return "TAG_enumeration_type";
- case TAG_formal_parameter: return "TAG_formal_parameter";
- case TAG_global_subroutine: return "TAG_global_subroutine";
- case TAG_global_variable: return "TAG_global_variable";
- case TAG_label: return "TAG_label";
- case TAG_lexical_block: return "TAG_lexical_block";
- case TAG_local_variable: return "TAG_local_variable";
- case TAG_member: return "TAG_member";
- case TAG_pointer_type: return "TAG_pointer_type";
- case TAG_reference_type: return "TAG_reference_type";
- case TAG_compile_unit: return "TAG_compile_unit";
- case TAG_string_type: return "TAG_string_type";
- case TAG_structure_type: return "TAG_structure_type";
- case TAG_subroutine: return "TAG_subroutine";
- case TAG_subroutine_type: return "TAG_subroutine_type";
- case TAG_typedef: return "TAG_typedef";
- case TAG_union_type: return "TAG_union_type";
- case TAG_unspecified_parameters: return "TAG_unspecified_parameters";
- case TAG_variant: return "TAG_variant";
- case TAG_common_block: return "TAG_common_block";
- case TAG_common_inclusion: return "TAG_common_inclusion";
- case TAG_inheritance: return "TAG_inheritance";
- case TAG_inlined_subroutine: return "TAG_inlined_subroutine";
- case TAG_module: return "TAG_module";
- case TAG_ptr_to_member_type: return "TAG_ptr_to_member_type";
- case TAG_set_type: return "TAG_set_type";
- case TAG_subrange_type: return "TAG_subrange_type";
- case TAG_with_stmt: return "TAG_with_stmt";
-
- /* GNU extensions. */
-
- case TAG_format_label: return "TAG_format_label";
- case TAG_namelist: return "TAG_namelist";
- case TAG_function_template: return "TAG_function_template";
- case TAG_class_template: return "TAG_class_template";
-
- default: return "TAG_<unknown>";
- }
-}
-
-static const char *
-dwarf_attr_name (unsigned int attr)
-{
- switch (attr)
- {
- case AT_sibling: return "AT_sibling";
- case AT_location: return "AT_location";
- case AT_name: return "AT_name";
- case AT_fund_type: return "AT_fund_type";
- case AT_mod_fund_type: return "AT_mod_fund_type";
- case AT_user_def_type: return "AT_user_def_type";
- case AT_mod_u_d_type: return "AT_mod_u_d_type";
- case AT_ordering: return "AT_ordering";
- case AT_subscr_data: return "AT_subscr_data";
- case AT_byte_size: return "AT_byte_size";
- case AT_bit_offset: return "AT_bit_offset";
- case AT_bit_size: return "AT_bit_size";
- case AT_element_list: return "AT_element_list";
- case AT_stmt_list: return "AT_stmt_list";
- case AT_low_pc: return "AT_low_pc";
- case AT_high_pc: return "AT_high_pc";
- case AT_language: return "AT_language";
- case AT_member: return "AT_member";
- case AT_discr: return "AT_discr";
- case AT_discr_value: return "AT_discr_value";
- case AT_string_length: return "AT_string_length";
- case AT_common_reference: return "AT_common_reference";
- case AT_comp_dir: return "AT_comp_dir";
- case AT_const_value_string: return "AT_const_value_string";
- case AT_const_value_data2: return "AT_const_value_data2";
- case AT_const_value_data4: return "AT_const_value_data4";
- case AT_const_value_data8: return "AT_const_value_data8";
- case AT_const_value_block2: return "AT_const_value_block2";
- case AT_const_value_block4: return "AT_const_value_block4";
- case AT_containing_type: return "AT_containing_type";
- case AT_default_value_addr: return "AT_default_value_addr";
- case AT_default_value_data2: return "AT_default_value_data2";
- case AT_default_value_data4: return "AT_default_value_data4";
- case AT_default_value_data8: return "AT_default_value_data8";
- case AT_default_value_string: return "AT_default_value_string";
- case AT_friends: return "AT_friends";
- case AT_inline: return "AT_inline";
- case AT_is_optional: return "AT_is_optional";
- case AT_lower_bound_ref: return "AT_lower_bound_ref";
- case AT_lower_bound_data2: return "AT_lower_bound_data2";
- case AT_lower_bound_data4: return "AT_lower_bound_data4";
- case AT_lower_bound_data8: return "AT_lower_bound_data8";
- case AT_private: return "AT_private";
- case AT_producer: return "AT_producer";
- case AT_program: return "AT_program";
- case AT_protected: return "AT_protected";
- case AT_prototyped: return "AT_prototyped";
- case AT_public: return "AT_public";
- case AT_pure_virtual: return "AT_pure_virtual";
- case AT_return_addr: return "AT_return_addr";
- case AT_abstract_origin: return "AT_abstract_origin";
- case AT_start_scope: return "AT_start_scope";
- case AT_stride_size: return "AT_stride_size";
- case AT_upper_bound_ref: return "AT_upper_bound_ref";
- case AT_upper_bound_data2: return "AT_upper_bound_data2";
- case AT_upper_bound_data4: return "AT_upper_bound_data4";
- case AT_upper_bound_data8: return "AT_upper_bound_data8";
- case AT_virtual: return "AT_virtual";
-
- /* GNU extensions */
-
- case AT_sf_names: return "AT_sf_names";
- case AT_src_info: return "AT_src_info";
- case AT_mac_info: return "AT_mac_info";
- case AT_src_coords: return "AT_src_coords";
- case AT_body_begin: return "AT_body_begin";
- case AT_body_end: return "AT_body_end";
-
- default: return "AT_<unknown>";
- }
-}
-
-static const char *
-dwarf_stack_op_name (unsigned int op)
-{
- switch (op)
- {
- case OP_REG: return "OP_REG";
- case OP_BASEREG: return "OP_BASEREG";
- case OP_ADDR: return "OP_ADDR";
- case OP_CONST: return "OP_CONST";
- case OP_DEREF2: return "OP_DEREF2";
- case OP_DEREF4: return "OP_DEREF4";
- case OP_ADD: return "OP_ADD";
- default: return "OP_<unknown>";
- }
-}
-
-static const char *
-dwarf_typemod_name (unsigned int mod)
-{
- switch (mod)
- {
- case MOD_pointer_to: return "MOD_pointer_to";
- case MOD_reference_to: return "MOD_reference_to";
- case MOD_const: return "MOD_const";
- case MOD_volatile: return "MOD_volatile";
- default: return "MOD_<unknown>";
- }
-}
-
-static const char *
-dwarf_fmt_byte_name (unsigned int fmt)
-{
- switch (fmt)
- {
- case FMT_FT_C_C: return "FMT_FT_C_C";
- case FMT_FT_C_X: return "FMT_FT_C_X";
- case FMT_FT_X_C: return "FMT_FT_X_C";
- case FMT_FT_X_X: return "FMT_FT_X_X";
- case FMT_UT_C_C: return "FMT_UT_C_C";
- case FMT_UT_C_X: return "FMT_UT_C_X";
- case FMT_UT_X_C: return "FMT_UT_X_C";
- case FMT_UT_X_X: return "FMT_UT_X_X";
- case FMT_ET: return "FMT_ET";
- default: return "FMT_<unknown>";
- }
-}
-
-static const char *
-dwarf_fund_type_name (unsigned int ft)
-{
- switch (ft)
- {
- case FT_char: return "FT_char";
- case FT_signed_char: return "FT_signed_char";
- case FT_unsigned_char: return "FT_unsigned_char";
- case FT_short: return "FT_short";
- case FT_signed_short: return "FT_signed_short";
- case FT_unsigned_short: return "FT_unsigned_short";
- case FT_integer: return "FT_integer";
- case FT_signed_integer: return "FT_signed_integer";
- case FT_unsigned_integer: return "FT_unsigned_integer";
- case FT_long: return "FT_long";
- case FT_signed_long: return "FT_signed_long";
- case FT_unsigned_long: return "FT_unsigned_long";
- case FT_pointer: return "FT_pointer";
- case FT_float: return "FT_float";
- case FT_dbl_prec_float: return "FT_dbl_prec_float";
- case FT_ext_prec_float: return "FT_ext_prec_float";
- case FT_complex: return "FT_complex";
- case FT_dbl_prec_complex: return "FT_dbl_prec_complex";
- case FT_void: return "FT_void";
- case FT_boolean: return "FT_boolean";
- case FT_ext_prec_complex: return "FT_ext_prec_complex";
- case FT_label: return "FT_label";
-
- /* GNU extensions. */
-
- case FT_long_long: return "FT_long_long";
- case FT_signed_long_long: return "FT_signed_long_long";
- case FT_unsigned_long_long: return "FT_unsigned_long_long";
-
- case FT_int8: return "FT_int8";
- case FT_signed_int8: return "FT_signed_int8";
- case FT_unsigned_int8: return "FT_unsigned_int8";
- case FT_int16: return "FT_int16";
- case FT_signed_int16: return "FT_signed_int16";
- case FT_unsigned_int16: return "FT_unsigned_int16";
- case FT_int32: return "FT_int32";
- case FT_signed_int32: return "FT_signed_int32";
- case FT_unsigned_int32: return "FT_unsigned_int32";
- case FT_int64: return "FT_int64";
- case FT_signed_int64: return "FT_signed_int64";
- case FT_unsigned_int64: return "FT_unsigned_int64";
- case FT_int128: return "FT_int128";
- case FT_signed_int128: return "FT_signed_int128";
- case FT_unsigned_int128: return "FT_unsigned_int128";
-
- case FT_real32: return "FT_real32";
- case FT_real64: return "FT_real64";
- case FT_real96: return "FT_real96";
- case FT_real128: return "FT_real128";
-
- default: return "FT_<unknown>";
- }
-}
-
-/* Determine the "ultimate origin" of a decl. The decl may be an
- inlined instance of an inlined instance of a decl which is local
- to an inline function, so we have to trace all of the way back
- through the origin chain to find out what sort of node actually
- served as the original seed for the given block. */
-
-static tree
-decl_ultimate_origin (tree decl)
-{
-#ifdef ENABLE_CHECKING
- if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
- /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
- most distant ancestor, this should never happen. */
- abort ();
-#endif
-
- return DECL_ABSTRACT_ORIGIN (decl);
-}
-
-/* Determine the "ultimate origin" of a block. The block may be an
- inlined instance of an inlined instance of a block which is local
- to an inline function, so we have to trace all of the way back
- through the origin chain to find out what sort of node actually
- served as the original seed for the given block. */
-
-static tree
-block_ultimate_origin (tree block)
-{
- tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
-
- if (immediate_origin == NULL)
- return NULL;
- else
- {
- tree ret_val;
- tree lookahead = immediate_origin;
-
- do
- {
- ret_val = lookahead;
- lookahead = (TREE_CODE (ret_val) == BLOCK)
- ? BLOCK_ABSTRACT_ORIGIN (ret_val)
- : NULL;
- }
- while (lookahead != NULL && lookahead != ret_val);
- return ret_val;
- }
-}
-
-/* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
- of a virtual function may refer to a base class, so we check the 'this'
- parameter. */
-
-static tree
-decl_class_context (tree decl)
-{
- tree context = NULL_TREE;
- if (TREE_CODE (decl) != FUNCTION_DECL || ! DECL_VINDEX (decl))
- context = DECL_CONTEXT (decl);
- else
- context = TYPE_MAIN_VARIANT
- (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
-
- if (context && !TYPE_P (context))
- context = NULL_TREE;
-
- return context;
-}
-
-#if 0
-static void
-output_unsigned_leb128 (unsigned long value)
-{
- unsigned long orig_value = value;
-
- do
- {
- unsigned byte = (value & 0x7f);
-
- value >>= 7;
- if (value != 0) /* more bytes to follow */
- byte |= 0x80;
- dw2_asm_output_data (1, byte, "\t%s ULEB128 number - value = %lu",
- orig_value);
- }
- while (value != 0);
-}
-
-static void
-output_signed_leb128 (long value)
-{
- long orig_value = value;
- int negative = (value < 0);
- int more;
-
- do
- {
- unsigned byte = (value & 0x7f);
-
- value >>= 7;
- if (negative)
- value |= 0xfe000000; /* manually sign extend */
- if (((value == 0) && ((byte & 0x40) == 0))
- || ((value == -1) && ((byte & 0x40) == 1)))
- more = 0;
- else
- {
- byte |= 0x80;
- more = 1;
- }
- dw2_asm_output_data (1, byte, "\t%s SLEB128 number - value = %ld",
- orig_value);
- }
- while (more);
-}
-#endif
-
-/**************** utility functions for attribute functions ******************/
-
-/* Given a pointer to a tree node for some type, return a Dwarf fundamental
- type code for the given type.
-
- This routine must only be called for GCC type nodes that correspond to
- Dwarf fundamental types.
-
- The current Dwarf draft specification calls for Dwarf fundamental types
- to accurately reflect the fact that a given type was either a "plain"
- integral type or an explicitly "signed" integral type. Unfortunately,
- we can't always do this, because GCC may already have thrown away the
- information about the precise way in which the type was originally
- specified, as in:
-
- typedef signed int my_type;
-
- struct s { my_type f; };
-
- Since we may be stuck here without enough information to do exactly
- what is called for in the Dwarf draft specification, we do the best
- that we can under the circumstances and always use the "plain" integral
- fundamental type codes for int, short, and long types. That's probably
- good enough. The additional accuracy called for in the current DWARF
- draft specification is probably never even useful in practice. */
-
-static int
-fundamental_type_code (tree type)
-{
- if (TREE_CODE (type) == ERROR_MARK)
- return 0;
-
- switch (TREE_CODE (type))
- {
- case ERROR_MARK:
- return FT_void;
-
- case VOID_TYPE:
- return FT_void;
-
- case INTEGER_TYPE:
- /* Carefully distinguish all the standard types of C,
- without messing up if the language is not C.
- Note that we check only for the names that contain spaces;
- other names might occur by coincidence in other languages. */
- if (TYPE_NAME (type) != 0
- && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
- && DECL_NAME (TYPE_NAME (type)) != 0
- && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
- {
- const char *const name =
- IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
-
- if (!strcmp (name, "unsigned char"))
- return FT_unsigned_char;
- if (!strcmp (name, "signed char"))
- return FT_signed_char;
- if (!strcmp (name, "unsigned int"))
- return FT_unsigned_integer;
- if (!strcmp (name, "short int"))
- return FT_short;
- if (!strcmp (name, "short unsigned int"))
- return FT_unsigned_short;
- if (!strcmp (name, "long int"))
- return FT_long;
- if (!strcmp (name, "long unsigned int"))
- return FT_unsigned_long;
- if (!strcmp (name, "long long int"))
- return FT_long_long; /* Not grok'ed by svr4 SDB */
- if (!strcmp (name, "long long unsigned int"))
- return FT_unsigned_long_long; /* Not grok'ed by svr4 SDB */
- }
-
- /* Most integer types will be sorted out above, however, for the
- sake of special `array index' integer types, the following code
- is also provided. */
-
- if (TYPE_PRECISION (type) == INT_TYPE_SIZE)
- return (TREE_UNSIGNED (type) ? FT_unsigned_integer : FT_integer);
-
- if (TYPE_PRECISION (type) == LONG_TYPE_SIZE)
- return (TREE_UNSIGNED (type) ? FT_unsigned_long : FT_long);
-
- if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE)
- return (TREE_UNSIGNED (type) ? FT_unsigned_long_long : FT_long_long);
-
- if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE)
- return (TREE_UNSIGNED (type) ? FT_unsigned_short : FT_short);
-
- if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE)
- return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char);
-
- if (TYPE_MODE (type) == TImode)
- return (TREE_UNSIGNED (type) ? FT_unsigned_int128 : FT_int128);
-
- /* In C++, __java_boolean is an INTEGER_TYPE with precision == 1 */
- if (TYPE_PRECISION (type) == 1)
- return FT_boolean;
-
- abort ();
-
- case REAL_TYPE:
- /* Carefully distinguish all the standard types of C,
- without messing up if the language is not C. */
- if (TYPE_NAME (type) != 0
- && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
- && DECL_NAME (TYPE_NAME (type)) != 0
- && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
- {
- const char *const name =
- IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
-
- /* Note that here we can run afoul of a serious bug in "classic"
- svr4 SDB debuggers. They don't seem to understand the
- FT_ext_prec_float type (even though they should). */
-
- if (!strcmp (name, "long double"))
- return FT_ext_prec_float;
- }
-
- if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
- {
- /* On the SH, when compiling with -m3e or -m4-single-only, both
- float and double are 32 bits. But since the debugger doesn't
- know about the subtarget, it always thinks double is 64 bits.
- So we have to tell the debugger that the type is float to
- make the output of the 'print' command etc. readable. */
- if (DOUBLE_TYPE_SIZE == FLOAT_TYPE_SIZE && FLOAT_TYPE_SIZE == 32)
- return FT_float;
- return FT_dbl_prec_float;
- }
- if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
- return FT_float;
-
- /* Note that here we can run afoul of a serious bug in "classic"
- svr4 SDB debuggers. They don't seem to understand the
- FT_ext_prec_float type (even though they should). */
-
- if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE)
- return FT_ext_prec_float;
- abort ();
-
- case COMPLEX_TYPE:
- return FT_complex; /* GNU FORTRAN COMPLEX type. */
-
- case CHAR_TYPE:
- return FT_char; /* GNU Pascal CHAR type. Not used in C. */
-
- case BOOLEAN_TYPE:
- return FT_boolean; /* GNU FORTRAN BOOLEAN type. */
-
- default:
- abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
- }
- return 0;
-}
-
-/* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
- the Dwarf "root" type for the given input type. The Dwarf "root" type
- of a given type is generally the same as the given type, except that if
- the given type is a pointer or reference type, then the root type of
- the given type is the root type of the "basis" type for the pointer or
- reference type. (This definition of the "root" type is recursive.)
- Also, the root type of a `const' qualified type or a `volatile'
- qualified type is the root type of the given type without the
- qualifiers. */
-
-static tree
-root_type_1 (tree type, int count)
-{
- /* Give up after searching 1000 levels, in case this is a recursive
- pointer type. Such types are possible in Ada, but it is not possible
- to represent them in DWARF1 debug info. */
- if (count > 1000)
- return error_mark_node;
-
- switch (TREE_CODE (type))
- {
- case ERROR_MARK:
- return error_mark_node;
-
- case POINTER_TYPE:
- case REFERENCE_TYPE:
- return root_type_1 (TREE_TYPE (type), count+1);
-
- default:
- return type;
- }
-}
-
-static tree
-root_type (tree type)
-{
- type = root_type_1 (type, 0);
- if (type != error_mark_node)
- type = type_main_variant (type);
- return type;
-}
-
-/* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
- of zero or more Dwarf "type-modifier" bytes applicable to the type. */
-
-static void
-write_modifier_bytes_1 (tree type, int decl_const, int decl_volatile, int count)
-{
- if (TREE_CODE (type) == ERROR_MARK)
- return;
-
- /* Give up after searching 1000 levels, in case this is a recursive
- pointer type. Such types are possible in Ada, but it is not possible
- to represent them in DWARF1 debug info. */
- if (count > 1000)
- return;
-
- if (TYPE_READONLY (type) || decl_const)
- ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const);
- if (TYPE_VOLATILE (type) || decl_volatile)
- ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_volatile);
- switch (TREE_CODE (type))
- {
- case POINTER_TYPE:
- ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to);
- write_modifier_bytes_1 (TREE_TYPE (type), 0, 0, count+1);
- return;
-
- case REFERENCE_TYPE:
- ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to);
- write_modifier_bytes_1 (TREE_TYPE (type), 0, 0, count+1);
- return;
-
- case ERROR_MARK:
- default:
- return;
- }
-}
-
-static void
-write_modifier_bytes (tree type, int decl_const, int decl_volatile)
-{
- write_modifier_bytes_1 (type, decl_const, decl_volatile, 0);
-}
-
-/* Given a pointer to an arbitrary ..._TYPE tree node, return nonzero if the
- given input type is a Dwarf "fundamental" type. Otherwise return zero. */
-
-static inline int
-type_is_fundamental (tree type)
-{
- switch (TREE_CODE (type))
- {
- case ERROR_MARK:
- case VOID_TYPE:
- case INTEGER_TYPE:
- case REAL_TYPE:
- case COMPLEX_TYPE:
- case BOOLEAN_TYPE:
- case CHAR_TYPE:
- return 1;
-
- case SET_TYPE:
- case ARRAY_TYPE:
- case RECORD_TYPE:
- case UNION_TYPE:
- case QUAL_UNION_TYPE:
- case ENUMERAL_TYPE:
- case FUNCTION_TYPE:
- case METHOD_TYPE:
- case POINTER_TYPE:
- case REFERENCE_TYPE:
- case FILE_TYPE:
- case OFFSET_TYPE:
- case LANG_TYPE:
- case VECTOR_TYPE:
- return 0;
-
- default:
- abort ();
- }
- return 0;
-}
-
-/* Given a pointer to some ..._DECL tree node, generate an assembly language
- equate directive which will associate a symbolic name with the current DIE.
-
- The name used is an artificial label generated from the DECL_UID number
- associated with the given decl node. The name it gets equated to is the
- symbolic label that we (previously) output at the start of the DIE that
- we are currently generating.
-
- Calling this function while generating some "decl related" form of DIE
- makes it possible to later refer to the DIE which represents the given
- decl simply by re-generating the symbolic name from the ..._DECL node's
- UID number. */
-
-static void
-equate_decl_number_to_die_number (tree decl)
-{
- /* In the case where we are generating a DIE for some ..._DECL node
- which represents either some inline function declaration or some
- entity declared within an inline function declaration/definition,
- setup a symbolic name for the current DIE so that we have a name
- for this DIE that we can easily refer to later on within
- AT_abstract_origin attributes. */
-
- char decl_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl));
- sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label);
-}
-
-/* Given a pointer to some ..._TYPE tree node, generate an assembly language
- equate directive which will associate a symbolic name with the current DIE.
-
- The name used is an artificial label generated from the TYPE_UID number
- associated with the given type node. The name it gets equated to is the
- symbolic label that we (previously) output at the start of the DIE that
- we are currently generating.
-
- Calling this function while generating some "type related" form of DIE
- makes it easy to later refer to the DIE which represents the given type
- simply by re-generating the alternative name from the ..._TYPE node's
- UID number. */
-
-static inline void
-equate_type_number_to_die_number (tree type)
-{
- char type_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- /* We are generating a DIE to represent the main variant of this type
- (i.e the type without any const or volatile qualifiers) so in order
- to get the equate to come out right, we need to get the main variant
- itself here. */
-
- type = type_main_variant (type);
-
- sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type));
- sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DEF (asm_out_file, type_label, die_label);
-}
-
-static void
-output_reg_number (rtx rtl)
-{
- unsigned regno = REGNO (rtl);
-
- if (regno >= DWARF_FRAME_REGISTERS)
- {
- warning ("%Jinternal regno botch: '%D' has regno = %d\n",
- dwarf_last_decl, dwarf_last_decl, regno);
- regno = 0;
- }
- dw2_assemble_integer (4, GEN_INT (DBX_REGISTER_NUMBER (regno)));
- if (flag_debug_asm)
- {
- fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
- PRINT_REG (rtl, 0, asm_out_file);
- }
- fputc ('\n', asm_out_file);
-}
-
-/* The following routine is a nice and simple transducer. It converts the
- RTL for a variable or parameter (resident in memory) into an equivalent
- Dwarf representation of a mechanism for getting the address of that same
- variable onto the top of a hypothetical "address evaluation" stack.
-
- When creating memory location descriptors, we are effectively trans-
- forming the RTL for a memory-resident object into its Dwarf postfix
- expression equivalent. This routine just recursively descends an
- RTL tree, turning it into Dwarf postfix code as it goes. */
-
-static void
-output_mem_loc_descriptor (rtx rtl)
-{
- /* Note that for a dynamically sized array, the location we will
- generate a description of here will be the lowest numbered location
- which is actually within the array. That's *not* necessarily the
- same as the zeroth element of the array. */
-
- rtl = (*targetm.delegitimize_address) (rtl);
-
- switch (GET_CODE (rtl))
- {
- case SUBREG:
-
- /* The case of a subreg may arise when we have a local (register)
- variable or a formal (register) parameter which doesn't quite
- fill up an entire register. For now, just assume that it is
- legitimate to make the Dwarf info refer to the whole register
- which contains the given subreg. */
-
- rtl = SUBREG_REG (rtl);
- /* Drop through. */
-
- case REG:
-
- /* Whenever a register number forms a part of the description of
- the method for calculating the (dynamic) address of a memory
- resident object, DWARF rules require the register number to
- be referred to as a "base register". This distinction is not
- based in any way upon what category of register the hardware
- believes the given register belongs to. This is strictly
- DWARF terminology we're dealing with here.
-
- Note that in cases where the location of a memory-resident data
- object could be expressed as:
-
- OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
-
- the actual DWARF location descriptor that we generate may just
- be OP_BASEREG (basereg). This may look deceptively like the
- object in question was allocated to a register (rather than
- in memory) so DWARF consumers need to be aware of the subtle
- distinction between OP_REG and OP_BASEREG. */
-
- ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
- output_reg_number (rtl);
- break;
-
- case MEM:
- output_mem_loc_descriptor (XEXP (rtl, 0));
- ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_DEREF4);
- break;
-
- case CONST:
- case SYMBOL_REF:
- ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADDR);
- ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
- break;
-
- case PLUS:
- output_mem_loc_descriptor (XEXP (rtl, 0));
- output_mem_loc_descriptor (XEXP (rtl, 1));
- ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
- break;
-
- case CONST_INT:
- ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl));
- break;
-
- case MULT:
- /* If a pseudo-reg is optimized away, it is possible for it to
- be replaced with a MEM containing a multiply. Use a GNU extension
- to describe it. */
- output_mem_loc_descriptor (XEXP (rtl, 0));
- output_mem_loc_descriptor (XEXP (rtl, 1));
- ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_MULT);
- break;
-
- default:
- abort ();
- }
-}
-
-/* Output a proper Dwarf location descriptor for a variable or parameter
- which is either allocated in a register or in a memory location. For
- a register, we just generate an OP_REG and the register number. For a
- memory location we provide a Dwarf postfix expression describing how to
- generate the (dynamic) address of the object onto the address stack. */
-
-static void
-output_loc_descriptor (rtx rtl)
-{
- switch (GET_CODE (rtl))
- {
- case SUBREG:
-
- /* The case of a subreg may arise when we have a local (register)
- variable or a formal (register) parameter which doesn't quite
- fill up an entire register. For now, just assume that it is
- legitimate to make the Dwarf info refer to the whole register
- which contains the given subreg. */
-
- rtl = SUBREG_REG (rtl);
- /* Drop through. */
-
- case REG:
- ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
- output_reg_number (rtl);
- break;
-
- case MEM:
- output_mem_loc_descriptor (XEXP (rtl, 0));
- break;
-
- default:
- abort (); /* Should never happen */
- }
-}
-
-/* Given a tree node describing an array bound (either lower or upper)
- output a representation for that bound. DIM_NUM is used for
- multi-dimensional arrays and U_OR_L designates upper or lower
- bound. */
-
-static void
-output_bound_representation (tree bound, unsigned int dim_num, char u_or_l)
-{
- switch (TREE_CODE (bound))
- {
-
- case ERROR_MARK:
- return;
-
- /* All fixed-bounds are represented by INTEGER_CST nodes. */
-
- case INTEGER_CST:
- if (host_integerp (bound, 0))
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, tree_low_cst (bound, 0));
- break;
-
- default:
-
- /* Dynamic bounds may be represented by NOP_EXPR nodes containing
- SAVE_EXPR nodes, in which case we can do something, or as
- an expression, which we cannot represent. */
- {
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
- current_dienum, dim_num, u_or_l);
-
- sprintf (end_label, BOUND_END_LABEL_FMT,
- current_dienum, dim_num, u_or_l);
-
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
-
- /* If optimization is turned on, the SAVE_EXPRs that describe
- how to access the upper bound values are essentially bogus.
- They only describe (at best) how to get at these values at
- the points in the generated code right after they have just
- been computed. Worse yet, in the typical case, the upper
- bound values will not even *be* computed in the optimized
- code, so these SAVE_EXPRs are entirely bogus.
-
- In order to compensate for this fact, we check here to see
- if optimization is enabled, and if so, we effectively create
- an empty location description for the (unknown and unknowable)
- upper bound.
-
- This should not cause too much trouble for existing (stupid?)
- debuggers because they have to deal with empty upper bounds
- location descriptions anyway in order to be able to deal with
- incomplete array types.
-
- Of course an intelligent debugger (GDB?) should be able to
- comprehend that a missing upper bound specification in a
- array type used for a storage class `auto' local array variable
- indicates that the upper bound is both unknown (at compile-
- time) and unknowable (at run-time) due to optimization. */
-
- if (! optimize)
- {
- while (TREE_CODE (bound) == NOP_EXPR
- || TREE_CODE (bound) == CONVERT_EXPR)
- bound = TREE_OPERAND (bound, 0);
-
- if (TREE_CODE (bound) == SAVE_EXPR
- && SAVE_EXPR_RTL (bound))
- output_loc_descriptor
- (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
- }
-
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
- }
- break;
-
- }
-}
-
-/* Recursive function to output a sequence of value/name pairs for
- enumeration constants in reversed order. This is called from
- enumeration_type_die. */
-
-static void
-output_enumeral_list (tree link)
-{
- if (link)
- {
- output_enumeral_list (TREE_CHAIN (link));
-
- if (host_integerp (TREE_VALUE (link), 0))
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
- tree_low_cst (TREE_VALUE (link), 0));
-
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
- IDENTIFIER_POINTER (TREE_PURPOSE (link)));
- }
-}
-
-/* Given an unsigned value, round it up to the lowest multiple of `boundary'
- which is not less than the value itself. */
-
-static inline HOST_WIDE_INT
-ceiling (HOST_WIDE_INT value, unsigned int boundary)
-{
- return (((value + boundary - 1) / boundary) * boundary);
-}
-
-/* Given a pointer to what is assumed to be a FIELD_DECL node, return a
- pointer to the declared type for the relevant field variable, or return
- `integer_type_node' if the given node turns out to be an ERROR_MARK node. */
-
-static inline tree
-field_type (tree decl)
-{
- tree type;
-
- if (TREE_CODE (decl) == ERROR_MARK)
- return integer_type_node;
-
- type = DECL_BIT_FIELD_TYPE (decl);
- if (type == NULL)
- type = TREE_TYPE (decl);
- return type;
-}
-
-/* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
- node, return the alignment in bits for the type, or else return
- BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
-
-static inline unsigned int
-simple_type_align_in_bits (tree type)
-{
- return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
-}
-
-/* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
- node, return the size in bits for the type if it is a constant, or
- else return the alignment for the type if the type's size is not
- constant, or else return BITS_PER_WORD if the type actually turns out
- to be an ERROR_MARK node. */
-
-static inline unsigned HOST_WIDE_INT
-simple_type_size_in_bits (tree type)
-{
- tree type_size_tree;
-
- if (TREE_CODE (type) == ERROR_MARK)
- return BITS_PER_WORD;
- type_size_tree = TYPE_SIZE (type);
-
- if (type_size_tree == NULL_TREE)
- return 0;
- if (! host_integerp (type_size_tree, 1))
- return TYPE_ALIGN (type);
- return tree_low_cst (type_size_tree, 1);
-}
-
-/* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
- return the byte offset of the lowest addressed byte of the "containing
- object" for the given FIELD_DECL, or return 0 if we are unable to deter-
- mine what that offset is, either because the argument turns out to be a
- pointer to an ERROR_MARK node, or because the offset is actually variable.
- (We can't handle the latter case just yet.) */
-
-static HOST_WIDE_INT
-field_byte_offset (tree decl)
-{
- unsigned int type_align_in_bytes;
- unsigned int type_align_in_bits;
- unsigned HOST_WIDE_INT type_size_in_bits;
- HOST_WIDE_INT object_offset_in_align_units;
- HOST_WIDE_INT object_offset_in_bits;
- HOST_WIDE_INT object_offset_in_bytes;
- tree type;
- tree field_size_tree;
- HOST_WIDE_INT bitpos_int;
- HOST_WIDE_INT deepest_bitpos;
- unsigned HOST_WIDE_INT field_size_in_bits;
-
- if (TREE_CODE (decl) == ERROR_MARK)
- return 0;
-
- if (TREE_CODE (decl) != FIELD_DECL)
- abort ();
-
- type = field_type (decl);
- field_size_tree = DECL_SIZE (decl);
-
- /* The size could be unspecified if there was an error, or for
- a flexible array member. */
- if (! field_size_tree)
- field_size_tree = bitsize_zero_node;
-
- /* We cannot yet cope with fields whose positions or sizes are variable,
- so for now, when we see such things, we simply return 0. Someday,
- we may be able to handle such cases, but it will be damn difficult. */
-
- if (! host_integerp (bit_position (decl), 0)
- || ! host_integerp (field_size_tree, 1))
- return 0;
-
- bitpos_int = int_bit_position (decl);
- field_size_in_bits = tree_low_cst (field_size_tree, 1);
-
- type_size_in_bits = simple_type_size_in_bits (type);
- type_align_in_bits = simple_type_align_in_bits (type);
- type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
-
- /* Note that the GCC front-end doesn't make any attempt to keep track
- of the starting bit offset (relative to the start of the containing
- structure type) of the hypothetical "containing object" for a bit-
- field. Thus, when computing the byte offset value for the start of
- the "containing object" of a bit-field, we must deduce this infor-
- mation on our own.
-
- This can be rather tricky to do in some cases. For example, handling
- the following structure type definition when compiling for an i386/i486
- target (which only aligns long long's to 32-bit boundaries) can be very
- tricky:
-
- struct S {
- int field1;
- long long field2:31;
- };
-
- Fortunately, there is a simple rule-of-thumb which can be used in such
- cases. When compiling for an i386/i486, GCC will allocate 8 bytes for
- the structure shown above. It decides to do this based upon one simple
- rule for bit-field allocation. Quite simply, GCC allocates each "con-
- taining object" for each bit-field at the first (i.e. lowest addressed)
- legitimate alignment boundary (based upon the required minimum alignment
- for the declared type of the field) which it can possibly use, subject
- to the condition that there is still enough available space remaining
- in the containing object (when allocated at the selected point) to
- fully accommodate all of the bits of the bit-field itself.
-
- This simple rule makes it obvious why GCC allocates 8 bytes for each
- object of the structure type shown above. When looking for a place to
- allocate the "containing object" for `field2', the compiler simply tries
- to allocate a 64-bit "containing object" at each successive 32-bit
- boundary (starting at zero) until it finds a place to allocate that 64-
- bit field such that at least 31 contiguous (and previously unallocated)
- bits remain within that selected 64 bit field. (As it turns out, for
- the example above, the compiler finds that it is OK to allocate the
- "containing object" 64-bit field at bit-offset zero within the
- structure type.)
-
- Here we attempt to work backwards from the limited set of facts we're
- given, and we try to deduce from those facts, where GCC must have
- believed that the containing object started (within the structure type).
-
- The value we deduce is then used (by the callers of this routine) to
- generate AT_location and AT_bit_offset attributes for fields (both
- bit-fields and, in the case of AT_location, regular fields as well). */
-
- /* Figure out the bit-distance from the start of the structure to the
- "deepest" bit of the bit-field. */
- deepest_bitpos = bitpos_int + field_size_in_bits;
-
- /* This is the tricky part. Use some fancy footwork to deduce where the
- lowest addressed bit of the containing object must be. */
- object_offset_in_bits
- = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
-
- /* Compute the offset of the containing object in "alignment units". */
- object_offset_in_align_units = object_offset_in_bits / type_align_in_bits;
-
- /* Compute the offset of the containing object in bytes. */
- object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
-
- /* The above code assumes that the field does not cross an alignment
- boundary. This can happen if PCC_BITFIELD_TYPE_MATTERS is not defined,
- or if the structure is packed. If this happens, then we get an object
- which starts after the bitfield, which means that the bit offset is
- negative. Gdb fails when given negative bit offsets. We avoid this
- by recomputing using the first bit of the bitfield. This will give
- us an object which does not completely contain the bitfield, but it
- will be aligned, and it will contain the first bit of the bitfield.
-
- However, only do this for a BYTES_BIG_ENDIAN target. For a
- ! BYTES_BIG_ENDIAN target, bitpos_int + field_size_in_bits is the first
- first bit of the bitfield. If we recompute using bitpos_int + 1 below,
- then we end up computing the object byte offset for the wrong word of the
- desired bitfield, which in turn causes the field offset to be negative
- in bit_offset_attribute. */
- if (BYTES_BIG_ENDIAN
- && object_offset_in_bits > bitpos_int)
- {
- deepest_bitpos = bitpos_int + 1;
- object_offset_in_bits
- = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
- object_offset_in_align_units = (object_offset_in_bits
- / type_align_in_bits);
- object_offset_in_bytes = (object_offset_in_align_units
- * type_align_in_bytes);
- }
-
- return object_offset_in_bytes;
-}
-
-/****************************** attributes *********************************/
-
-/* The following routines are responsible for writing out the various types
- of Dwarf attributes (and any following data bytes associated with them).
- These routines are listed in order based on the numerical codes of their
- associated attributes. */
-
-/* Generate an AT_sibling attribute. */
-
-static inline void
-sibling_attribute (void)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sibling);
- sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
- ASM_OUTPUT_DWARF_REF (asm_out_file, label);
-}
-
-/* Output the form of location attributes suitable for whole variables and
- whole parameters. Note that the location attributes for struct fields
- are generated by the routine `data_member_location_attribute' below. */
-
-static void
-location_attribute (rtx rtl)
-{
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
- sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
- sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
-
- /* Handle a special case. If we are about to output a location descriptor
- for a variable or parameter which has been optimized out of existence,
- don't do that. Instead we output a zero-length location descriptor
- value as part of the location attribute.
-
- A variable which has been optimized out of existence will have a
- DECL_RTL value which denotes a pseudo-reg.
-
- Currently, in some rare cases, variables can have DECL_RTL values
- which look like (MEM (REG pseudo-reg#)). These cases are due to
- bugs elsewhere in the compiler. We treat such cases
- as if the variable(s) in question had been optimized out of existence.
-
- Note that in all cases where we wish to express the fact that a
- variable has been optimized out of existence, we do not simply
- suppress the generation of the entire location attribute because
- the absence of a location attribute in certain kinds of DIEs is
- used to indicate something else entirely... i.e. that the DIE
- represents an object declaration, but not a definition. So saith
- the PLSIG.
- */
-
- if (! is_pseudo_reg (rtl)
- && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0))))
- output_loc_descriptor (rtl);
-
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
-}
-
-/* Output the specialized form of location attribute used for data members
- of struct and union types.
-
- In the special case of a FIELD_DECL node which represents a bit-field,
- the "offset" part of this special location descriptor must indicate the
- distance in bytes from the lowest-addressed byte of the containing
- struct or union type to the lowest-addressed byte of the "containing
- object" for the bit-field. (See the `field_byte_offset' function above.)
-
- For any given bit-field, the "containing object" is a hypothetical
- object (of some integral or enum type) within which the given bit-field
- lives. The type of this hypothetical "containing object" is always the
- same as the declared type of the individual bit-field itself (for GCC
- anyway... the DWARF spec doesn't actually mandate this).
-
- Note that it is the size (in bytes) of the hypothetical "containing
- object" which will be given in the AT_byte_size attribute for this
- bit-field. (See the `byte_size_attribute' function below.) It is
- also used when calculating the value of the AT_bit_offset attribute.
- (See the `bit_offset_attribute' function below.) */
-
-static void
-data_member_location_attribute (tree t)
-{
- unsigned object_offset_in_bytes;
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- if (TREE_CODE (t) == TREE_VEC)
- object_offset_in_bytes = tree_low_cst (BINFO_OFFSET (t), 0);
- else
- object_offset_in_bytes = field_byte_offset (t);
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
- sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
- sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
- ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, object_offset_in_bytes);
- ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
-}
-
-/* Output an AT_const_value attribute for a variable or a parameter which
- does not have a "location" either in memory or in a register. These
- things can arise in GNU C when a constant is passed as an actual
- parameter to an inlined function. They can also arise in C++ where
- declared constants do not necessarily get memory "homes". */
-
-static void
-const_value_attribute (rtx rtl)
-{
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_const_value_block4);
- sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
- sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
-
- switch (GET_CODE (rtl))
- {
- case CONST_INT:
- /* Note that a CONST_INT rtx could represent either an integer or
- a floating-point constant. A CONST_INT is used whenever the
- constant will fit into a single word. In all such cases, the
- original mode of the constant value is wiped out, and the
- CONST_INT rtx is assigned VOIDmode. Since we no longer have
- precise mode information for these constants, we always just
- output them using 4 bytes. */
-
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) INTVAL (rtl));
- break;
-
- case CONST_DOUBLE:
- /* Note that a CONST_DOUBLE rtx could represent either an integer
- or a floating-point constant. A CONST_DOUBLE is used whenever
- the constant requires more than one word in order to be adequately
- represented. In all such cases, the original mode of the constant
- value is preserved as the mode of the CONST_DOUBLE rtx, but for
- simplicity we always just output CONST_DOUBLEs using 8 bytes. */
-
- ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
- (unsigned int) CONST_DOUBLE_HIGH (rtl),
- (unsigned int) CONST_DOUBLE_LOW (rtl));
- break;
-
- case CONST_STRING:
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, XSTR (rtl, 0));
- break;
-
- case SYMBOL_REF:
- case LABEL_REF:
- case CONST:
- ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
- break;
-
- case PLUS:
- /* In cases where an inlined instance of an inline function is passed
- the address of an `auto' variable (which is local to the caller)
- we can get a situation where the DECL_RTL of the artificial
- local variable (for the inlining) which acts as a stand-in for
- the corresponding formal parameter (of the inline function)
- will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
- This is not exactly a compile-time constant expression, but it
- isn't the address of the (artificial) local variable either.
- Rather, it represents the *value* which the artificial local
- variable always has during its lifetime. We currently have no
- way to represent such quasi-constant values in Dwarf, so for now
- we just punt and generate an AT_const_value attribute with form
- FORM_BLOCK4 and a length of zero. */
- break;
-
- default:
- abort (); /* No other kinds of rtx should be possible here. */
- }
-
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
-}
-
-/* Generate *either* an AT_location attribute or else an AT_const_value
- data attribute for a variable or a parameter. We generate the
- AT_const_value attribute only in those cases where the given
- variable or parameter does not have a true "location" either in
- memory or in a register. This can happen (for example) when a
- constant is passed as an actual argument in a call to an inline
- function. (It's possible that these things can crop up in other
- ways also.) Note that one type of constant value which can be
- passed into an inlined function is a constant pointer. This can
- happen for example if an actual argument in an inlined function
- call evaluates to a compile-time constant address. */
-
-static void
-location_or_const_value_attribute (tree decl)
-{
- rtx rtl;
-
- if (TREE_CODE (decl) == ERROR_MARK)
- return;
-
- if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL))
- {
- /* Should never happen. */
- abort ();
- return;
- }
-
- /* Here we have to decide where we are going to say the parameter "lives"
- (as far as the debugger is concerned). We only have a couple of choices.
- GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL
- normally indicates where the parameter lives during most of the activa-
- tion of the function. If optimization is enabled however, this could
- be either NULL or else a pseudo-reg. Both of those cases indicate that
- the parameter doesn't really live anywhere (as far as the code generation
- parts of GCC are concerned) during most of the function's activation.
- That will happen (for example) if the parameter is never referenced
- within the function.
-
- We could just generate a location descriptor here for all non-NULL
- non-pseudo values of DECL_RTL and ignore all of the rest, but we can
- be a little nicer than that if we also consider DECL_INCOMING_RTL in
- cases where DECL_RTL is NULL or is a pseudo-reg.
-
- Note however that we can only get away with using DECL_INCOMING_RTL as
- a backup substitute for DECL_RTL in certain limited cases. In cases
- where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
- we can be sure that the parameter was passed using the same type as it
- is declared to have within the function, and that its DECL_INCOMING_RTL
- points us to a place where a value of that type is passed. In cases
- where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
- however, we cannot (in general) use DECL_INCOMING_RTL as a backup
- substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
- points us to a value of some type which is *different* from the type
- of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL
- to generate a location attribute in such cases, the debugger would
- end up (for example) trying to fetch a `float' from a place which
- actually contains the first part of a `double'. That would lead to
- really incorrect and confusing output at debug-time, and we don't
- want that now do we?
-
- So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
- in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a
- couple of cute exceptions however. On little-endian machines we can
- get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
- not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
- an integral type which is smaller than TREE_TYPE(decl). These cases
- arise when (on a little-endian machine) a non-prototyped function has
- a parameter declared to be of type `short' or `char'. In such cases,
- TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
- `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
- passed `int' value. If the debugger then uses that address to fetch a
- `short' or a `char' (on a little-endian machine) the result will be the
- correct data, so we allow for such exceptional cases below.
-
- Note that our goal here is to describe the place where the given formal
- parameter lives during most of the function's activation (i.e. between
- the end of the prologue and the start of the epilogue). We'll do that
- as best as we can. Note however that if the given formal parameter is
- modified sometime during the execution of the function, then a stack
- backtrace (at debug-time) will show the function as having been called
- with the *new* value rather than the value which was originally passed
- in. This happens rarely enough that it is not a major problem, but it
- *is* a problem, and I'd like to fix it. A future version of dwarfout.c
- may generate two additional attributes for any given TAG_formal_parameter
- DIE which will describe the "passed type" and the "passed location" for
- the given formal parameter in addition to the attributes we now generate
- to indicate the "declared type" and the "active location" for each
- parameter. This additional set of attributes could be used by debuggers
- for stack backtraces.
-
- Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
- can be NULL also. This happens (for example) for inlined-instances of
- inline function formal parameters which are never referenced. This really
- shouldn't be happening. All PARM_DECL nodes should get valid non-NULL
- DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
- these values for inlined instances of inline function parameters, so
- when we see such cases, we are just out-of-luck for the time
- being (until integrate.c gets fixed).
- */
-
- /* Use DECL_RTL as the "location" unless we find something better. */
- rtl = DECL_RTL (decl);
-
- if (TREE_CODE (decl) == PARM_DECL)
- if (rtl == NULL_RTX || is_pseudo_reg (rtl))
- {
- /* This decl represents a formal parameter which was optimized out. */
- tree declared_type = type_main_variant (TREE_TYPE (decl));
- tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
-
- /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
- *all* cases where (rtl == NULL_RTX) just below. */
-
- if (declared_type == passed_type)
- rtl = DECL_INCOMING_RTL (decl);
- else if (! BYTES_BIG_ENDIAN)
- if (TREE_CODE (declared_type) == INTEGER_TYPE)
- /* NMS WTF? */
- if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
- rtl = DECL_INCOMING_RTL (decl);
- }
-
- if (rtl == NULL_RTX)
- return;
-
- rtl = eliminate_regs (rtl, 0, NULL_RTX);
-#ifdef LEAF_REG_REMAP
- if (current_function_uses_only_leaf_regs)
- leaf_renumber_regs_insn (rtl);
-#endif
-
- switch (GET_CODE (rtl))
- {
- case ADDRESSOF:
- /* The address of a variable that was optimized away; don't emit
- anything. */
- break;
-
- case CONST_INT:
- case CONST_DOUBLE:
- case CONST_STRING:
- case SYMBOL_REF:
- case LABEL_REF:
- case CONST:
- case PLUS: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
- const_value_attribute (rtl);
- break;
-
- case MEM:
- case REG:
- case SUBREG:
- location_attribute (rtl);
- break;
-
- case CONCAT:
- /* ??? CONCAT is used for complex variables, which may have the real
- part stored in one place and the imag part stored somewhere else.
- DWARF1 has no way to describe a variable that lives in two different
- places, so we just describe where the first part lives, and hope that
- the second part is stored after it. */
- location_attribute (XEXP (rtl, 0));
- break;
-
- default:
- abort (); /* Should never happen. */
- }
-}
-
-/* Generate an AT_name attribute given some string value to be included as
- the value of the attribute. */
-
-static inline void
-name_attribute (const char *name_string)
-{
- if (name_string && *name_string)
- {
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, name_string);
- }
-}
-
-static inline void
-fund_type_attribute (unsigned int ft_code)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type);
- ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code);
-}
-
-static void
-mod_fund_type_attribute (tree type, int decl_const, int decl_volatile)
-{
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_fund_type);
- sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
- sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
- write_modifier_bytes (type, decl_const, decl_volatile);
- ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
- fundamental_type_code (root_type (type)));
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
-}
-
-static inline void
-user_def_type_attribute (tree type)
-{
- char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_user_def_type);
- sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (type));
- ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
-}
-
-static void
-mod_u_d_type_attribute (tree type, int decl_const, int decl_volatile)
-{
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_u_d_type);
- sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
- sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
- write_modifier_bytes (type, decl_const, decl_volatile);
- sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (root_type (type)));
- ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
-}
-
-#ifdef USE_ORDERING_ATTRIBUTE
-static inline void
-ordering_attribute (unsigned ordering)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
-}
-#endif /* defined(USE_ORDERING_ATTRIBUTE) */
-
-/* Note that the block of subscript information for an array type also
- includes information about the element type of type given array type. */
-
-static void
-subscript_data_attribute (tree type)
-{
- unsigned dimension_number;
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_subscr_data);
- sprintf (begin_label, SS_BEGIN_LABEL_FMT, current_dienum);
- sprintf (end_label, SS_END_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
-
- /* The GNU compilers represent multidimensional array types as sequences
- of one dimensional array types whose element types are themselves array
- types. Here we squish that down, so that each multidimensional array
- type gets only one array_type DIE in the Dwarf debugging info. The
- draft Dwarf specification say that we are allowed to do this kind
- of compression in C (because there is no difference between an
- array or arrays and a multidimensional array in C) but for other
- source languages (e.g. Ada) we probably shouldn't do this. */
-
- for (dimension_number = 0;
- TREE_CODE (type) == ARRAY_TYPE;
- type = TREE_TYPE (type), dimension_number++)
- {
- tree domain = TYPE_DOMAIN (type);
-
- /* Arrays come in three flavors. Unspecified bounds, fixed
- bounds, and (in GNU C only) variable bounds. Handle all
- three forms here. */
-
- if (domain)
- {
- /* We have an array type with specified bounds. */
-
- tree lower = TYPE_MIN_VALUE (domain);
- tree upper = TYPE_MAX_VALUE (domain);
-
- /* Handle only fundamental types as index types for now. */
- if (! type_is_fundamental (domain))
- abort ();
-
- /* Output the representation format byte for this dimension. */
- ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file,
- FMT_CODE (1, TREE_CODE (lower) == INTEGER_CST,
- upper && TREE_CODE (upper) == INTEGER_CST));
-
- /* Output the index type for this dimension. */
- ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
- fundamental_type_code (domain));
-
- /* Output the representation for the lower bound. */
- output_bound_representation (lower, dimension_number, 'l');
-
- /* Output the representation for the upper bound. */
- if (upper)
- output_bound_representation (upper, dimension_number, 'u');
- else
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
- }
- else
- {
- /* We have an array type with an unspecified length. For C and
- C++ we can assume that this really means that (a) the index
- type is an integral type, and (b) the lower bound is zero.
- Note that Dwarf defines the representation of an unspecified
- (upper) bound as being a zero-length location description. */
-
- /* Output the array-bounds format byte. */
-
- ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_FT_C_X);
-
- /* Output the (assumed) index type. */
-
- ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, FT_integer);
-
- /* Output the (assumed) lower bound (constant) value. */
-
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
-
- /* Output the (empty) location description for the upper bound. */
-
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
- }
- }
-
- /* Output the prefix byte that says that the element type is coming up. */
-
- ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET);
-
- /* Output a representation of the type of the elements of this array type. */
-
- type_attribute (type, 0, 0);
-
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
-}
-
-static void
-byte_size_attribute (tree tree_node)
-{
- unsigned size;
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size);
- switch (TREE_CODE (tree_node))
- {
- case ERROR_MARK:
- size = 0;
- break;
-
- case ENUMERAL_TYPE:
- case RECORD_TYPE:
- case UNION_TYPE:
- case QUAL_UNION_TYPE:
- case ARRAY_TYPE:
- size = int_size_in_bytes (tree_node);
- break;
-
- case FIELD_DECL:
- /* For a data member of a struct or union, the AT_byte_size is
- generally given as the number of bytes normally allocated for
- an object of the *declared* type of the member itself. This
- is true even for bit-fields. */
- size = simple_type_size_in_bits (field_type (tree_node))
- / BITS_PER_UNIT;
- break;
-
- default:
- abort ();
- }
-
- /* Note that `size' might be -1 when we get to this point. If it
- is, that indicates that the byte size of the entity in question
- is variable. We have no good way of expressing this fact in Dwarf
- at the present time, so just let the -1 pass on through. */
-
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size);
-}
-
-/* For a FIELD_DECL node which represents a bit-field, output an attribute
- which specifies the distance in bits from the highest order bit of the
- "containing object" for the bit-field to the highest order bit of the
- bit-field itself.
-
- For any given bit-field, the "containing object" is a hypothetical
- object (of some integral or enum type) within which the given bit-field
- lives. The type of this hypothetical "containing object" is always the
- same as the declared type of the individual bit-field itself.
-
- The determination of the exact location of the "containing object" for
- a bit-field is rather complicated. It's handled by the `field_byte_offset'
- function (above).
-
- Note that it is the size (in bytes) of the hypothetical "containing
- object" which will be given in the AT_byte_size attribute for this
- bit-field. (See `byte_size_attribute' above.) */
-
-static inline void
-bit_offset_attribute (tree decl)
-{
- HOST_WIDE_INT object_offset_in_bytes = field_byte_offset (decl);
- tree type = DECL_BIT_FIELD_TYPE (decl);
- HOST_WIDE_INT bitpos_int;
- HOST_WIDE_INT highest_order_object_bit_offset;
- HOST_WIDE_INT highest_order_field_bit_offset;
- HOST_WIDE_INT bit_offset;
-
- /* Must be a bit field. */
- if (!type
- || TREE_CODE (decl) != FIELD_DECL)
- abort ();
-
- /* We can't yet handle bit-fields whose offsets or sizes are variable, so
- if we encounter such things, just return without generating any
- attribute whatsoever. */
-
- if (! host_integerp (bit_position (decl), 0)
- || ! host_integerp (DECL_SIZE (decl), 1))
- return;
-
- bitpos_int = int_bit_position (decl);
-
- /* Note that the bit offset is always the distance (in bits) from the
- highest-order bit of the "containing object" to the highest-order
- bit of the bit-field itself. Since the "high-order end" of any
- object or field is different on big-endian and little-endian machines,
- the computation below must take account of these differences. */
-
- highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
- highest_order_field_bit_offset = bitpos_int;
-
- if (! BYTES_BIG_ENDIAN)
- {
- highest_order_field_bit_offset += tree_low_cst (DECL_SIZE (decl), 1);
- highest_order_object_bit_offset += simple_type_size_in_bits (type);
- }
-
- bit_offset =
- (! BYTES_BIG_ENDIAN
- ? highest_order_object_bit_offset - highest_order_field_bit_offset
- : highest_order_field_bit_offset - highest_order_object_bit_offset);
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset);
-}
-
-/* For a FIELD_DECL node which represents a bit field, output an attribute
- which specifies the length in bits of the given field. */
-
-static inline void
-bit_size_attribute (tree decl)
-{
- /* Must be a field and a bit field. */
- if (TREE_CODE (decl) != FIELD_DECL
- || ! DECL_BIT_FIELD_TYPE (decl))
- abort ();
-
- if (host_integerp (DECL_SIZE (decl), 1))
- {
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
- tree_low_cst (DECL_SIZE (decl), 1));
- }
-}
-
-/* The following routine outputs the `element_list' attribute for enumeration
- type DIEs. The element_lits attribute includes the names and values of
- all of the enumeration constants associated with the given enumeration
- type. */
-
-static inline void
-element_list_attribute (tree element)
-{
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_element_list);
- sprintf (begin_label, EE_BEGIN_LABEL_FMT, current_dienum);
- sprintf (end_label, EE_END_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
-
- /* Here we output a list of value/name pairs for each enumeration constant
- defined for this enumeration type (as required), but we do it in REVERSE
- order. The order is the one required by the draft #5 Dwarf specification
- published by the UI/PLSIG. */
-
- output_enumeral_list (element); /* Recursively output the whole list. */
-
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
-}
-
-/* Generate an AT_stmt_list attribute. These are normally present only in
- DIEs with a TAG_compile_unit tag. */
-
-static inline void
-stmt_list_attribute (const char *label)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list);
- /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
-}
-
-/* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
- for a subroutine DIE. */
-
-static inline void
-low_pc_attribute (const char *asm_low_label)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label);
-}
-
-/* Generate an AT_high_pc attribute for a lexical_block DIE or for a
- subroutine DIE. */
-
-static inline void
-high_pc_attribute (const char *asm_high_label)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label);
-}
-
-/* Generate an AT_body_begin attribute for a subroutine DIE. */
-
-static inline void
-body_begin_attribute (const char *asm_begin_label)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_begin_label);
-}
-
-/* Generate an AT_body_end attribute for a subroutine DIE. */
-
-static inline void
-body_end_attribute (const char *asm_end_label)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label);
-}
-
-/* Generate an AT_language attribute given a LANG value. These attributes
- are used only within TAG_compile_unit DIEs. */
-
-static inline void
-language_attribute (unsigned int language_code)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code);
-}
-
-static inline void
-member_attribute (tree context)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- /* Generate this attribute only for members in C++. */
-
- if (context != NULL && is_tagged_type (context))
- {
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member);
- sprintf (label, TYPE_NAME_FMT, TYPE_UID (context));
- ASM_OUTPUT_DWARF_REF (asm_out_file, label);
- }
-}
-
-#if 0
-#ifndef SL_BEGIN_LABEL_FMT
-#define SL_BEGIN_LABEL_FMT "*.L_sl%u"
-#endif
-#ifndef SL_END_LABEL_FMT
-#define SL_END_LABEL_FMT "*.L_sl%u_e"
-#endif
-
-static inline void
-string_length_attribute (tree upper_bound)
-{
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_string_length);
- sprintf (begin_label, SL_BEGIN_LABEL_FMT, current_dienum);
- sprintf (end_label, SL_END_LABEL_FMT, current_dienum);
- ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
- output_bound_representation (upper_bound, 0, 'u');
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
-}
-#endif
-
-static inline void
-comp_dir_attribute (const char *dirname)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
-}
-
-static inline void
-sf_names_attribute (const char *sf_names_start_label)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names);
- /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label);
-}
-
-static inline void
-src_info_attribute (const char *src_info_start_label)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info);
- /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label);
-}
-
-static inline void
-mac_info_attribute (const char *mac_info_start_label)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info);
- /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label);
-}
-
-static inline void
-prototyped_attribute (tree func_type)
-{
- if ((strcmp (lang_hooks.name, "GNU C") == 0)
- && (TYPE_ARG_TYPES (func_type) != NULL))
- {
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
- }
-}
-
-static inline void
-producer_attribute (const char *producer)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, producer);
-}
-
-static inline void
-inline_attribute (tree decl)
-{
- if (DECL_INLINE (decl))
- {
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
- }
-}
-
-static inline void
-containing_type_attribute (tree containing_type)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_containing_type);
- sprintf (label, TYPE_NAME_FMT, TYPE_UID (containing_type));
- ASM_OUTPUT_DWARF_REF (asm_out_file, label);
-}
-
-static inline void
-abstract_origin_attribute (tree origin)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin);
- switch (TREE_CODE_CLASS (TREE_CODE (origin)))
- {
- case 'd':
- sprintf (label, DECL_NAME_FMT, DECL_UID (origin));
- break;
-
- case 't':
- sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin));
- break;
-
- default:
- abort (); /* Should never happen. */
-
- }
- ASM_OUTPUT_DWARF_REF (asm_out_file, label);
-}
-
-#ifdef DWARF_DECL_COORDINATES
-static inline void
-src_coords_attribute (unsigned src_fileno, unsigned src_lineno)
-{
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno);
-}
-#endif /* defined(DWARF_DECL_COORDINATES) */
-
-static inline void
-pure_or_virtual_attribute (tree func_decl)
-{
- if (DECL_VIRTUAL_P (func_decl))
- {
-#if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */
- if (DECL_ABSTRACT_VIRTUAL_P (func_decl))
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
- else
-#endif
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
- }
-}
-
-/************************* end of attributes *****************************/
-
-/********************* utility routines for DIEs *************************/
-
-/* Output an AT_name attribute and an AT_src_coords attribute for the
- given decl, but only if it actually has a name. */
-
-static void
-name_and_src_coords_attributes (tree decl)
-{
- tree decl_name = DECL_NAME (decl);
-
- if (decl_name && IDENTIFIER_POINTER (decl_name))
- {
- name_attribute (IDENTIFIER_POINTER (decl_name));
-#ifdef DWARF_DECL_COORDINATES
- {
- register unsigned file_index;
-
- /* This is annoying, but we have to pop out of the .debug section
- for a moment while we call `lookup_filename' because calling it
- may cause a temporary switch into the .debug_sfnames section and
- most svr4 assemblers are not smart enough to be able to nest
- section switches to any depth greater than one. Note that we
- also can't skirt this issue by delaying all output to the
- .debug_sfnames section unit the end of compilation because that
- would cause us to have inter-section forward references and
- Fred Fish sez that m68k/svr4 assemblers botch those. */
-
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- file_index = lookup_filename (DECL_SOURCE_FILE (decl));
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
-
- src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
- }
-#endif /* defined(DWARF_DECL_COORDINATES) */
- }
-}
-
-/* Many forms of DIEs contain a "type description" part. The following
- routine writes out these "type descriptor" parts. */
-
-static void
-type_attribute (tree type, int decl_const, int decl_volatile)
-{
- enum tree_code code = TREE_CODE (type);
- int root_type_modified;
-
- if (code == ERROR_MARK)
- return;
-
- /* Handle a special case. For functions whose return type is void,
- we generate *no* type attribute. (Note that no object may have
- type `void', so this only applies to function return types. */
-
- if (code == VOID_TYPE)
- return;
-
- /* If this is a subtype, find the underlying type. Eventually,
- this should write out the appropriate subtype info. */
- while ((code == INTEGER_TYPE || code == REAL_TYPE)
- && TREE_TYPE (type) != 0)
- type = TREE_TYPE (type), code = TREE_CODE (type);
-
- root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE
- || decl_const || decl_volatile
- || TYPE_READONLY (type) || TYPE_VOLATILE (type));
-
- if (type_is_fundamental (root_type (type)))
- {
- if (root_type_modified)
- mod_fund_type_attribute (type, decl_const, decl_volatile);
- else
- fund_type_attribute (fundamental_type_code (type));
- }
- else
- {
- if (root_type_modified)
- mod_u_d_type_attribute (type, decl_const, decl_volatile);
- else
- /* We have to get the type_main_variant here (and pass that to the
- `user_def_type_attribute' routine) because the ..._TYPE node we
- have might simply be a *copy* of some original type node (where
- the copy was created to help us keep track of typedef names)
- and that copy might have a different TYPE_UID from the original
- ..._TYPE node. (Note that when `equate_type_number_to_die_number'
- is labeling a given type DIE for future reference, it always and
- only creates labels for DIEs representing *main variants*, and it
- never even knows about non-main-variants.) */
- user_def_type_attribute (type_main_variant (type));
- }
-}
-
-/* Given a tree pointer to a struct, class, union, or enum type node, return
- a pointer to the (string) tag name for the given type, or zero if the
- type was declared without a tag. */
-
-static const char *
-type_tag (tree type)
-{
- const char *name = 0;
-
- if (TYPE_NAME (type) != 0)
- {
- tree t = 0;
-
- /* Find the IDENTIFIER_NODE for the type name. */
- if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
- t = TYPE_NAME (type);
-
- /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
- a TYPE_DECL node, regardless of whether or not a `typedef' was
- involved. */
- else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
- && ! DECL_IGNORED_P (TYPE_NAME (type)))
- t = DECL_NAME (TYPE_NAME (type));
-
- /* Now get the name as a string, or invent one. */
- if (t != 0)
- name = IDENTIFIER_POINTER (t);
- }
-
- return (name == 0 || *name == '\0') ? 0 : name;
-}
-
-static inline void
-dienum_push (void)
-{
- /* Start by checking if the pending_sibling_stack needs to be expanded.
- If necessary, expand it. */
-
- if (pending_siblings == pending_siblings_allocated)
- {
- pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT;
- pending_sibling_stack
- = xrealloc (pending_sibling_stack,
- pending_siblings_allocated * sizeof(unsigned));
- }
-
- pending_siblings++;
- NEXT_DIE_NUM = next_unused_dienum++;
-}
-
-/* Pop the sibling stack so that the most recently pushed DIEnum becomes the
- NEXT_DIE_NUM. */
-
-static inline void
-dienum_pop (void)
-{
- pending_siblings--;
-}
-
-static inline tree
-member_declared_type (tree member)
-{
- return (DECL_BIT_FIELD_TYPE (member))
- ? DECL_BIT_FIELD_TYPE (member)
- : TREE_TYPE (member);
-}
-
-/* Get the function's label, as described by its RTL.
- This may be different from the DECL_NAME name used
- in the source file. */
-
-static const char *
-function_start_label (tree decl)
-{
- rtx x;
- const char *fnname;
-
- x = DECL_RTL (decl);
- if (GET_CODE (x) != MEM)
- abort ();
- x = XEXP (x, 0);
- if (GET_CODE (x) != SYMBOL_REF)
- abort ();
- fnname = XSTR (x, 0);
- return fnname;
-}
-
-
-/******************************* DIEs ************************************/
-
-/* Output routines for individual types of DIEs. */
-
-/* Note that every type of DIE (except a null DIE) gets a sibling. */
-
-static void
-output_array_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type);
- sibling_attribute ();
- equate_type_number_to_die_number (type);
- member_attribute (TYPE_CONTEXT (type));
-
- /* I believe that we can default the array ordering. SDB will probably
- do the right things even if AT_ordering is not present. It's not
- even an issue until we start to get into multidimensional arrays
- anyway. If SDB is ever caught doing the Wrong Thing for multi-
- dimensional arrays, then we'll have to put the AT_ordering attribute
- back in. (But if and when we find out that we need to put these in,
- we will only do so for multidimensional arrays. After all, we don't
- want to waste space in the .debug section now do we?) */
-
-#ifdef USE_ORDERING_ATTRIBUTE
- ordering_attribute (ORD_row_major);
-#endif /* defined(USE_ORDERING_ATTRIBUTE) */
-
- subscript_data_attribute (type);
-}
-
-static void
-output_set_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
- sibling_attribute ();
- equate_type_number_to_die_number (type);
- member_attribute (TYPE_CONTEXT (type));
- type_attribute (TREE_TYPE (type), 0, 0);
-}
-
-#if 0
-/* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
-
-static void
-output_entry_point_die (void *arg)
-{
- tree decl = arg;
- tree origin = decl_ultimate_origin (decl);
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
- sibling_attribute ();
- dienum_push ();
- if (origin != NULL)
- abstract_origin_attribute (origin);
- else
- {
- name_and_src_coords_attributes (decl);
- member_attribute (DECL_CONTEXT (decl));
- type_attribute (TREE_TYPE (TREE_TYPE (decl)), 0, 0);
- }
- if (DECL_ABSTRACT (decl))
- equate_decl_number_to_die_number (decl);
- else
- low_pc_attribute (function_start_label (decl));
-}
-#endif
-
-/* Output a DIE to represent an inlined instance of an enumeration type. */
-
-static void
-output_inlined_enumeration_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
- sibling_attribute ();
- if (!TREE_ASM_WRITTEN (type))
- abort ();
- abstract_origin_attribute (type);
-}
-
-/* Output a DIE to represent an inlined instance of a structure type. */
-
-static void
-output_inlined_structure_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
- sibling_attribute ();
- if (!TREE_ASM_WRITTEN (type))
- abort ();
- abstract_origin_attribute (type);
-}
-
-/* Output a DIE to represent an inlined instance of a union type. */
-
-static void
-output_inlined_union_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
- sibling_attribute ();
- if (!TREE_ASM_WRITTEN (type))
- abort ();
- abstract_origin_attribute (type);
-}
-
-/* Output a DIE to represent an enumeration type. Note that these DIEs
- include all of the information about the enumeration values also.
- This information is encoded into the element_list attribute. */
-
-static void
-output_enumeration_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
- sibling_attribute ();
- equate_type_number_to_die_number (type);
- name_attribute (type_tag (type));
- member_attribute (TYPE_CONTEXT (type));
-
- /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
- given enum type is incomplete, do not generate the AT_byte_size
- attribute or the AT_element_list attribute. */
-
- if (COMPLETE_TYPE_P (type))
- {
- byte_size_attribute (type);
- element_list_attribute (TYPE_FIELDS (type));
- }
-}
-
-/* Output a DIE to represent either a real live formal parameter decl or
- to represent just the type of some formal parameter position in some
- function type.
-
- Note that this routine is a bit unusual because its argument may be
- a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
- represents an inlining of some PARM_DECL) or else some sort of a
- ..._TYPE node. If it's the former then this function is being called
- to output a DIE to represent a formal parameter object (or some inlining
- thereof). If it's the latter, then this function is only being called
- to output a TAG_formal_parameter DIE to stand as a placeholder for some
- formal argument type of some subprogram type. */
-
-static void
-output_formal_parameter_die (void *arg)
-{
- tree node = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
- sibling_attribute ();
-
- switch (TREE_CODE_CLASS (TREE_CODE (node)))
- {
- case 'd': /* We were called with some kind of a ..._DECL node. */
- {
- tree origin = decl_ultimate_origin (node);
-
- if (origin != NULL)
- abstract_origin_attribute (origin);
- else
- {
- name_and_src_coords_attributes (node);
- type_attribute (TREE_TYPE (node),
- TREE_READONLY (node), TREE_THIS_VOLATILE (node));
- }
- if (DECL_ABSTRACT (node))
- equate_decl_number_to_die_number (node);
- else
- location_or_const_value_attribute (node);
- }
- break;
-
- case 't': /* We were called with some kind of a ..._TYPE node. */
- type_attribute (node, 0, 0);
- break;
-
- default:
- abort (); /* Should never happen. */
- }
-}
-
-/* Output a DIE to represent a declared function (either file-scope
- or block-local) which has "external linkage" (according to ANSI-C). */
-
-static void
-output_global_subroutine_die (void *arg)
-{
- tree decl = arg;
- tree origin = decl_ultimate_origin (decl);
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
- sibling_attribute ();
- dienum_push ();
- if (origin != NULL)
- abstract_origin_attribute (origin);
- else
- {
- tree type = TREE_TYPE (decl);
-
- name_and_src_coords_attributes (decl);
- inline_attribute (decl);
- prototyped_attribute (type);
- member_attribute (DECL_CONTEXT (decl));
- type_attribute (TREE_TYPE (type), 0, 0);
- pure_or_virtual_attribute (decl);
- }
- if (DECL_ABSTRACT (decl))
- equate_decl_number_to_die_number (decl);
- else
- {
- if (! DECL_EXTERNAL (decl) && ! in_class
- && decl == current_function_decl)
- {
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- low_pc_attribute (function_start_label (decl));
- sprintf (label, FUNC_END_LABEL_FMT, current_function_funcdef_no);
- high_pc_attribute (label);
- if (use_gnu_debug_info_extensions)
- {
- sprintf (label, BODY_BEGIN_LABEL_FMT,
- current_function_funcdef_no);
- body_begin_attribute (label);
- sprintf (label, BODY_END_LABEL_FMT, current_function_funcdef_no);
- body_end_attribute (label);
- }
- }
- }
-}
-
-/* Output a DIE to represent a declared data object (either file-scope
- or block-local) which has "external linkage" (according to ANSI-C). */
-
-static void
-output_global_variable_die (void *arg)
-{
- tree decl = arg;
- tree origin = decl_ultimate_origin (decl);
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
- sibling_attribute ();
- if (origin != NULL)
- abstract_origin_attribute (origin);
- else
- {
- name_and_src_coords_attributes (decl);
- member_attribute (DECL_CONTEXT (decl));
- type_attribute (TREE_TYPE (decl),
- TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
- }
- if (DECL_ABSTRACT (decl))
- equate_decl_number_to_die_number (decl);
- else
- {
- if (! DECL_EXTERNAL (decl) && ! in_class
- && current_function_decl == decl_function_context (decl))
- location_or_const_value_attribute (decl);
- }
-}
-
-static void
-output_label_die (void *arg)
-{
- tree decl = arg;
- tree origin = decl_ultimate_origin (decl);
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
- sibling_attribute ();
- if (origin != NULL)
- abstract_origin_attribute (origin);
- else
- name_and_src_coords_attributes (decl);
- if (DECL_ABSTRACT (decl))
- equate_decl_number_to_die_number (decl);
- else
- {
- rtx insn = DECL_RTL (decl);
-
- /* Deleted labels are programmer specified labels which have been
- eliminated because of various optimizations. We still emit them
- here so that it is possible to put breakpoints on them. */
- if (GET_CODE (insn) == CODE_LABEL
- || ((GET_CODE (insn) == NOTE
- && NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL)))
- {
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- /* When optimization is enabled (via -O) some parts of the compiler
- (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
- represent source-level labels which were explicitly declared by
- the user. This really shouldn't be happening though, so catch
- it if it ever does happen. */
-
- if (INSN_DELETED_P (insn))
- abort (); /* Should never happen. */
-
- ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (insn));
- low_pc_attribute (label);
- }
- }
-}
-
-static void
-output_lexical_block_die (void *arg)
-{
- tree stmt = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
- sibling_attribute ();
- dienum_push ();
- if (! BLOCK_ABSTRACT (stmt))
- {
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, BLOCK_NUMBER (stmt));
- low_pc_attribute (begin_label);
- sprintf (end_label, BLOCK_END_LABEL_FMT, BLOCK_NUMBER (stmt));
- high_pc_attribute (end_label);
- }
-}
-
-static void
-output_inlined_subroutine_die (void *arg)
-{
- tree stmt = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
- sibling_attribute ();
- dienum_push ();
- abstract_origin_attribute (block_ultimate_origin (stmt));
- if (! BLOCK_ABSTRACT (stmt))
- {
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, BLOCK_NUMBER (stmt));
- low_pc_attribute (begin_label);
- sprintf (end_label, BLOCK_END_LABEL_FMT, BLOCK_NUMBER (stmt));
- high_pc_attribute (end_label);
- }
-}
-
-/* Output a DIE to represent a declared data object (either file-scope
- or block-local) which has "internal linkage" (according to ANSI-C). */
-
-static void
-output_local_variable_die (void *arg)
-{
- tree decl = arg;
- tree origin = decl_ultimate_origin (decl);
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
- sibling_attribute ();
- if (origin != NULL)
- abstract_origin_attribute (origin);
- else
- {
- name_and_src_coords_attributes (decl);
- member_attribute (DECL_CONTEXT (decl));
- type_attribute (TREE_TYPE (decl),
- TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
- }
- if (DECL_ABSTRACT (decl))
- equate_decl_number_to_die_number (decl);
- else
- location_or_const_value_attribute (decl);
-}
-
-static void
-output_member_die (void *arg)
-{
- tree decl = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
- sibling_attribute ();
- name_and_src_coords_attributes (decl);
- member_attribute (DECL_CONTEXT (decl));
- type_attribute (member_declared_type (decl),
- TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
- if (DECL_BIT_FIELD_TYPE (decl)) /* If this is a bit field... */
- {
- byte_size_attribute (decl);
- bit_size_attribute (decl);
- bit_offset_attribute (decl);
- }
- data_member_location_attribute (decl);
-}
-
-#if 0
-/* Don't generate either pointer_type DIEs or reference_type DIEs. Use
- modified types instead.
-
- We keep this code here just in case these types of DIEs may be
- needed to represent certain things in other languages (e.g. Pascal)
- someday. */
-
-static void
-output_pointer_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type);
- sibling_attribute ();
- equate_type_number_to_die_number (type);
- member_attribute (TYPE_CONTEXT (type));
- type_attribute (TREE_TYPE (type), 0, 0);
-}
-
-static void
-output_reference_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type);
- sibling_attribute ();
- equate_type_number_to_die_number (type);
- member_attribute (TYPE_CONTEXT (type));
- type_attribute (TREE_TYPE (type), 0, 0);
-}
-#endif
-
-static void
-output_ptr_to_mbr_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type);
- sibling_attribute ();
- equate_type_number_to_die_number (type);
- member_attribute (TYPE_CONTEXT (type));
- containing_type_attribute (TYPE_OFFSET_BASETYPE (type));
- type_attribute (TREE_TYPE (type), 0, 0);
-}
-
-static void
-output_compile_unit_die (void *arg)
-{
- const char *main_input_filename = arg;
- const char *language_string = lang_hooks.name;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit);
- sibling_attribute ();
- dienum_push ();
- name_attribute (main_input_filename);
-
- {
- char producer[250];
-
- sprintf (producer, "%s %s", language_string, version_string);
- producer_attribute (producer);
- }
-
- if (strcmp (language_string, "GNU C++") == 0)
- language_attribute (LANG_C_PLUS_PLUS);
- else if (strcmp (language_string, "GNU Ada") == 0)
- language_attribute (LANG_ADA83);
- else if (strcmp (language_string, "GNU F77") == 0)
- language_attribute (LANG_FORTRAN77);
- else if (strcmp (language_string, "GNU Pascal") == 0)
- language_attribute (LANG_PASCAL83);
- else if (strcmp (language_string, "GNU Java") == 0)
- language_attribute (LANG_JAVA);
- else
- language_attribute (LANG_C89);
- low_pc_attribute (TEXT_BEGIN_LABEL);
- high_pc_attribute (TEXT_END_LABEL);
- if (debug_info_level >= DINFO_LEVEL_NORMAL)
- stmt_list_attribute (LINE_BEGIN_LABEL);
-
- {
- const char *wd = get_src_pwd ();
- if (wd)
- comp_dir_attribute (wd);
- }
-
- if (debug_info_level >= DINFO_LEVEL_NORMAL && use_gnu_debug_info_extensions)
- {
- sf_names_attribute (SFNAMES_BEGIN_LABEL);
- src_info_attribute (SRCINFO_BEGIN_LABEL);
- if (debug_info_level >= DINFO_LEVEL_VERBOSE)
- mac_info_attribute (MACINFO_BEGIN_LABEL);
- }
-}
-
-static void
-output_string_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type);
- sibling_attribute ();
- equate_type_number_to_die_number (type);
- member_attribute (TYPE_CONTEXT (type));
- /* This is a fixed length string. */
- byte_size_attribute (type);
-}
-
-static void
-output_inheritance_die (void *arg)
-{
- tree binfo = ((tree *)arg)[0];
- tree access = ((tree *)arg)[1];
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inheritance);
- sibling_attribute ();
- type_attribute (BINFO_TYPE (binfo), 0, 0);
- data_member_location_attribute (binfo);
- if (TREE_VIA_VIRTUAL (binfo))
- {
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
- }
- if (access == access_public_node)
- {
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_public);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
- }
- else if (access == access_protected_node)
- {
- ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_protected);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
- }
-}
-
-static void
-output_structure_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
- sibling_attribute ();
- equate_type_number_to_die_number (type);
- name_attribute (type_tag (type));
- member_attribute (TYPE_CONTEXT (type));
-
- /* If this type has been completed, then give it a byte_size attribute
- and prepare to give a list of members. Otherwise, don't do either of
- these things. In the latter case, we will not be generating a list
- of members (since we don't have any idea what they might be for an
- incomplete type). */
-
- if (COMPLETE_TYPE_P (type))
- {
- dienum_push ();
- byte_size_attribute (type);
- }
-}
-
-/* Output a DIE to represent a declared function (either file-scope
- or block-local) which has "internal linkage" (according to ANSI-C). */
-
-static void
-output_local_subroutine_die (void *arg)
-{
- tree decl = arg;
- tree origin = decl_ultimate_origin (decl);
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
- sibling_attribute ();
- dienum_push ();
- if (origin != NULL)
- abstract_origin_attribute (origin);
- else
- {
- tree type = TREE_TYPE (decl);
-
- name_and_src_coords_attributes (decl);
- inline_attribute (decl);
- prototyped_attribute (type);
- member_attribute (DECL_CONTEXT (decl));
- type_attribute (TREE_TYPE (type), 0, 0);
- pure_or_virtual_attribute (decl);
- }
- if (DECL_ABSTRACT (decl))
- equate_decl_number_to_die_number (decl);
- else
- {
- /* Avoid getting screwed up in cases where a function was declared
- static but where no definition was ever given for it. */
-
- if (TREE_ASM_WRITTEN (decl))
- {
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
- low_pc_attribute (function_start_label (decl));
- sprintf (label, FUNC_END_LABEL_FMT, current_function_funcdef_no);
- high_pc_attribute (label);
- if (use_gnu_debug_info_extensions)
- {
- sprintf (label, BODY_BEGIN_LABEL_FMT,
- current_function_funcdef_no);
- body_begin_attribute (label);
- sprintf (label, BODY_END_LABEL_FMT, current_function_funcdef_no);
- body_end_attribute (label);
- }
- }
- }
-}
-
-static void
-output_subroutine_type_die (void *arg)
-{
- tree type = arg;
- tree return_type = TREE_TYPE (type);
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type);
- sibling_attribute ();
- dienum_push ();
- equate_type_number_to_die_number (type);
- prototyped_attribute (type);
- member_attribute (TYPE_CONTEXT (type));
- type_attribute (return_type, 0, 0);
-}
-
-static void
-output_typedef_die (void *arg)
-{
- tree decl = arg;
- tree origin = decl_ultimate_origin (decl);
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
- sibling_attribute ();
- if (origin != NULL)
- abstract_origin_attribute (origin);
- else
- {
- name_and_src_coords_attributes (decl);
- member_attribute (DECL_CONTEXT (decl));
- type_attribute (TREE_TYPE (decl),
- TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
- }
- if (DECL_ABSTRACT (decl))
- equate_decl_number_to_die_number (decl);
-}
-
-static void
-output_union_type_die (void *arg)
-{
- tree type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
- sibling_attribute ();
- equate_type_number_to_die_number (type);
- name_attribute (type_tag (type));
- member_attribute (TYPE_CONTEXT (type));
-
- /* If this type has been completed, then give it a byte_size attribute
- and prepare to give a list of members. Otherwise, don't do either of
- these things. In the latter case, we will not be generating a list
- of members (since we don't have any idea what they might be for an
- incomplete type). */
-
- if (COMPLETE_TYPE_P (type))
- {
- dienum_push ();
- byte_size_attribute (type);
- }
-}
-
-/* Generate a special type of DIE used as a stand-in for a trailing ellipsis
- at the end of an (ANSI prototyped) formal parameters list. */
-
-static void
-output_unspecified_parameters_die (void *arg)
-{
- tree decl_or_type = arg;
-
- ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters);
- sibling_attribute ();
-
- /* This kludge is here only for the sake of being compatible with what
- the USL CI5 C compiler does. The specification of Dwarf Version 1
- doesn't say that TAG_unspecified_parameters DIEs should contain any
- attributes other than the AT_sibling attribute, but they are certainly
- allowed to contain additional attributes, and the CI5 compiler
- generates AT_name, AT_fund_type, and AT_location attributes within
- TAG_unspecified_parameters DIEs which appear in the child lists for
- DIEs representing function definitions, so we do likewise here. */
-
- if (TREE_CODE (decl_or_type) == FUNCTION_DECL && DECL_INITIAL (decl_or_type))
- {
- name_attribute ("...");
- fund_type_attribute (FT_pointer);
- /* location_attribute (?); */
- }
-}
-
-static void
-output_padded_null_die (void *arg ATTRIBUTE_UNUSED)
-{
- ASM_OUTPUT_ALIGN (asm_out_file, 2); /* 2**2 == 4 */
-}
-
-/*************************** end of DIEs *********************************/
-
-/* Generate some type of DIE. This routine generates the generic outer
- wrapper stuff which goes around all types of DIE's (regardless of their
- TAGs. All forms of DIEs start with a DIE-specific label, followed by a
- DIE-length word, followed by the guts of the DIE itself. After the guts
- of the DIE, there must always be a terminator label for the DIE. */
-
-static void
-output_die (void (*die_specific_output_function) (void *), void *param)
-{
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
- char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- current_dienum = NEXT_DIE_NUM;
- NEXT_DIE_NUM = next_unused_dienum;
-
- sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
- sprintf (end_label, DIE_END_LABEL_FMT, current_dienum);
-
- /* Write a label which will act as the name for the start of this DIE. */
-
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
-
- /* Write the DIE-length word. */
-
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
-
- /* Fill in the guts of the DIE. */
-
- next_unused_dienum++;
- die_specific_output_function (param);
-
- /* Write a label which will act as the name for the end of this DIE. */
-
- ASM_OUTPUT_LABEL (asm_out_file, end_label);
-}
-
-static void
-end_sibling_chain (void)
-{
- char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- current_dienum = NEXT_DIE_NUM;
- NEXT_DIE_NUM = next_unused_dienum;
-
- sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
-
- /* Write a label which will act as the name for the start of this DIE. */
-
- ASM_OUTPUT_LABEL (asm_out_file, begin_label);
-
- /* Write the DIE-length word. */
-
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4);
-
- dienum_pop ();
-}
-
-/* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
- TAG_unspecified_parameters DIE) to represent the types of the formal
- parameters as specified in some function type specification (except
- for those which appear as part of a function *definition*).
-
- Note that we must be careful here to output all of the parameter
- DIEs *before* we output any DIEs needed to represent the types of
- the formal parameters. This keeps svr4 SDB happy because it
- (incorrectly) thinks that the first non-parameter DIE it sees ends
- the formal parameter list. */
-
-static void
-output_formal_types (tree function_or_method_type)
-{
- tree link;
- tree formal_type = NULL;
- tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
-
- /* Set TREE_ASM_WRITTEN while processing the parameters, lest we
- get bogus recursion when outputting tagged types local to a
- function declaration. */
- int save_asm_written = TREE_ASM_WRITTEN (function_or_method_type);
- TREE_ASM_WRITTEN (function_or_method_type) = 1;
-
- /* In the case where we are generating a formal types list for a C++
- non-static member function type, skip over the first thing on the
- TYPE_ARG_TYPES list because it only represents the type of the
- hidden `this pointer'. The debugger should be able to figure
- out (without being explicitly told) that this non-static member
- function type takes a `this pointer' and should be able to figure
- what the type of that hidden parameter is from the AT_member
- attribute of the parent TAG_subroutine_type DIE. */
-
- if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
- first_parm_type = TREE_CHAIN (first_parm_type);
-
- /* Make our first pass over the list of formal parameter types and output
- a TAG_formal_parameter DIE for each one. */
-
- for (link = first_parm_type; link; link = TREE_CHAIN (link))
- {
- formal_type = TREE_VALUE (link);
- if (formal_type == void_type_node)
- break;
-
- /* Output a (nameless) DIE to represent the formal parameter itself. */
-
- output_die (output_formal_parameter_die, formal_type);
- }
-
- /* If this function type has an ellipsis, add a TAG_unspecified_parameters
- DIE to the end of the parameter list. */
-
- if (formal_type != void_type_node)
- output_die (output_unspecified_parameters_die, function_or_method_type);
-
- /* Make our second (and final) pass over the list of formal parameter types
- and output DIEs to represent those types (as necessary). */
-
- for (link = TYPE_ARG_TYPES (function_or_method_type);
- link;
- link = TREE_CHAIN (link))
- {
- formal_type = TREE_VALUE (link);
- if (formal_type == void_type_node)
- break;
-
- output_type (formal_type, function_or_method_type);
- }
-
- TREE_ASM_WRITTEN (function_or_method_type) = save_asm_written;
-}
-
-/* Remember a type in the pending_types_list. */
-
-static void
-pend_type (tree type)
-{
- if (pending_types == pending_types_allocated)
- {
- pending_types_allocated += PENDING_TYPES_INCREMENT;
- pending_types_list
- = xrealloc (pending_types_list,
- sizeof (tree) * pending_types_allocated);
- }
- pending_types_list[pending_types++] = type;
-
- /* Mark the pending type as having been output already (even though
- it hasn't been). This prevents the type from being added to the
- pending_types_list more than once. */
-
- TREE_ASM_WRITTEN (type) = 1;
-}
-
-/* Return nonzero if it is legitimate to output DIEs to represent a
- given type while we are generating the list of child DIEs for some
- DIE (e.g. a function or lexical block DIE) associated with a given scope.
-
- See the comments within the function for a description of when it is
- considered legitimate to output DIEs for various kinds of types.
-
- Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
- or it may point to a BLOCK node (for types local to a block), or to a
- FUNCTION_DECL node (for types local to the heading of some function
- definition), or to a FUNCTION_TYPE node (for types local to the
- prototyped parameter list of a function type specification), or to a
- RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
- (in the case of C++ nested types).
-
- The `scope' parameter should likewise be NULL or should point to a
- BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
- node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
-
- This function is used only for deciding when to "pend" and when to
- "un-pend" types to/from the pending_types_list.
-
- Note that we sometimes make use of this "type pending" feature in a
- rather twisted way to temporarily delay the production of DIEs for the
- types of formal parameters. (We do this just to make svr4 SDB happy.)
- It order to delay the production of DIEs representing types of formal
- parameters, callers of this function supply `fake_containing_scope' as
- the `scope' parameter to this function. Given that fake_containing_scope
- is a tagged type which is *not* the containing scope for *any* other type,
- the desired effect is achieved, i.e. output of DIEs representing types
- is temporarily suspended, and any type DIEs which would have otherwise
- been output are instead placed onto the pending_types_list. Later on,
- we force these (temporarily pended) types to be output simply by calling
- `output_pending_types_for_scope' with an actual argument equal to the
- true scope of the types we temporarily pended. */
-
-static inline int
-type_ok_for_scope (tree type, tree scope)
-{
- /* Tagged types (i.e. struct, union, and enum types) must always be
- output only in the scopes where they actually belong (or else the
- scoping of their own tag names and the scoping of their member
- names will be incorrect). Non-tagged-types on the other hand can
- generally be output anywhere, except that svr4 SDB really doesn't
- want to see them nested within struct or union types, so here we
- say it is always OK to immediately output any such a (non-tagged)
- type, so long as we are not within such a context. Note that the
- only kinds of non-tagged types which we will be dealing with here
- (for C and C++ anyway) will be array types and function types. */
-
- return is_tagged_type (type)
- ? (TYPE_CONTEXT (type) == scope
- /* Ignore namespaces for the moment. */
- || (scope == NULL_TREE
- && TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL)
- || (scope == NULL_TREE && is_tagged_type (TYPE_CONTEXT (type))
- && TREE_ASM_WRITTEN (TYPE_CONTEXT (type))))
- : (scope == NULL_TREE || ! is_tagged_type (scope));
-}
-
-/* Output any pending types (from the pending_types list) which we can output
- now (taking into account the scope that we are working on now).
-
- For each type output, remove the given type from the pending_types_list
- *before* we try to output it.
-
- Note that we have to process the list in beginning-to-end order,
- because the call made here to output_type may cause yet more types
- to be added to the end of the list, and we may have to output some
- of them too. */
-
-static void
-output_pending_types_for_scope (tree containing_scope)
-{
- unsigned i;
-
- for (i = 0; i < pending_types; )
- {
- tree type = pending_types_list[i];
-
- if (type_ok_for_scope (type, containing_scope))
- {
- tree *mover;
- tree *limit;
-
- pending_types--;
- limit = &pending_types_list[pending_types];
- for (mover = &pending_types_list[i]; mover < limit; mover++)
- *mover = *(mover+1);
-
- /* Un-mark the type as having been output already (because it
- hasn't been, really). Then call output_type to generate a
- Dwarf representation of it. */
-
- TREE_ASM_WRITTEN (type) = 0;
- output_type (type, containing_scope);
-
- /* Don't increment the loop counter in this case because we
- have shifted all of the subsequent pending types down one
- element in the pending_types_list array. */
- }
- else
- i++;
- }
-}
-
-/* Remember a type in the incomplete_types_list. */
-
-static void
-add_incomplete_type (tree type)
-{
- if (incomplete_types == incomplete_types_allocated)
- {
- incomplete_types_allocated += INCOMPLETE_TYPES_INCREMENT;
- incomplete_types_list
- = xrealloc (incomplete_types_list,
- sizeof (tree) * incomplete_types_allocated);
- }
-
- incomplete_types_list[incomplete_types++] = type;
-}
-
-/* Walk through the list of incomplete types again, trying once more to
- emit full debugging info for them. */
-
-static void
-retry_incomplete_types (void)
-{
- tree type;
-
- finalizing = 1;
- while (incomplete_types)
- {
- --incomplete_types;
- type = incomplete_types_list[incomplete_types];
- output_type (type, NULL_TREE);
- }
-}
-
-static void
-output_type (tree type, tree containing_scope)
-{
- if (type == 0 || type == error_mark_node)
- return;
-
- /* We are going to output a DIE to represent the unqualified version of
- this type (i.e. without any const or volatile qualifiers) so get
- the main variant (i.e. the unqualified version) of this type now. */
-
- type = type_main_variant (type);
-
- if (TREE_ASM_WRITTEN (type))
- {
- if (finalizing && AGGREGATE_TYPE_P (type))
- {
- tree member;
-
- /* Some of our nested types might not have been defined when we
- were written out before; force them out now. */
-
- for (member = TYPE_FIELDS (type); member;
- member = TREE_CHAIN (member))
- if (TREE_CODE (member) == TYPE_DECL
- && ! TREE_ASM_WRITTEN (TREE_TYPE (member)))
- output_type (TREE_TYPE (member), containing_scope);
- }
- return;
- }
-
- /* If this is a nested type whose containing class hasn't been
- written out yet, writing it out will cover this one, too. */
-
- if (TYPE_CONTEXT (type)
- && TYPE_P (TYPE_CONTEXT (type))
- && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
- {
- output_type (TYPE_CONTEXT (type), containing_scope);
- return;
- }
-
- /* Don't generate any DIEs for this type now unless it is OK to do so
- (based upon what `type_ok_for_scope' tells us). */
-
- if (! type_ok_for_scope (type, containing_scope))
- {
- pend_type (type);
- return;
- }
-
- switch (TREE_CODE (type))
- {
- case ERROR_MARK:
- break;
-
- case VECTOR_TYPE:
- output_type (TYPE_DEBUG_REPRESENTATION_TYPE (type), containing_scope);
- break;
-
- case POINTER_TYPE:
- case REFERENCE_TYPE:
- /* Prevent infinite recursion in cases where this is a recursive
- type. Recursive types are possible in Ada. */
- TREE_ASM_WRITTEN (type) = 1;
- /* For these types, all that is required is that we output a DIE
- (or a set of DIEs) to represent the "basis" type. */
- output_type (TREE_TYPE (type), containing_scope);
- break;
-
- case OFFSET_TYPE:
- /* This code is used for C++ pointer-to-data-member types. */
- /* Output a description of the relevant class type. */
- output_type (TYPE_OFFSET_BASETYPE (type), containing_scope);
- /* Output a description of the type of the object pointed to. */
- output_type (TREE_TYPE (type), containing_scope);
- /* Now output a DIE to represent this pointer-to-data-member type
- itself. */
- output_die (output_ptr_to_mbr_type_die, type);
- break;
-
- case SET_TYPE:
- output_type (TYPE_DOMAIN (type), containing_scope);
- output_die (output_set_type_die, type);
- break;
-
- case FILE_TYPE:
- output_type (TREE_TYPE (type), containing_scope);
- abort (); /* No way to represent these in Dwarf yet! */
- break;
-
- case FUNCTION_TYPE:
- /* Force out return type (in case it wasn't forced out already). */
- output_type (TREE_TYPE (type), containing_scope);
- output_die (output_subroutine_type_die, type);
- output_formal_types (type);
- end_sibling_chain ();
- break;
-
- case METHOD_TYPE:
- /* Force out return type (in case it wasn't forced out already). */
- output_type (TREE_TYPE (type), containing_scope);
- output_die (output_subroutine_type_die, type);
- output_formal_types (type);
- end_sibling_chain ();
- break;
-
- case ARRAY_TYPE:
- if (TYPE_STRING_FLAG (type) && TREE_CODE(TREE_TYPE(type)) == CHAR_TYPE)
- {
- output_type (TREE_TYPE (type), containing_scope);
- output_die (output_string_type_die, type);
- }
- else
- {
- tree element_type;
-
- element_type = TREE_TYPE (type);
- while (TREE_CODE (element_type) == ARRAY_TYPE)
- element_type = TREE_TYPE (element_type);
-
- output_type (element_type, containing_scope);
- output_die (output_array_type_die, type);
- }
- break;
-
- case ENUMERAL_TYPE:
- case RECORD_TYPE:
- case UNION_TYPE:
- case QUAL_UNION_TYPE:
-
- /* For a non-file-scope tagged type, we can always go ahead and
- output a Dwarf description of this type right now, even if
- the type in question is still incomplete, because if this
- local type *was* ever completed anywhere within its scope,
- that complete definition would already have been attached to
- this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
- node by the time we reach this point. That's true because of the
- way the front-end does its processing of file-scope declarations (of
- functions and class types) within which other types might be
- nested. The C and C++ front-ends always gobble up such "local
- scope" things en-mass before they try to output *any* debugging
- information for any of the stuff contained inside them and thus,
- we get the benefit here of what is (in effect) a pre-resolution
- of forward references to tagged types in local scopes.
-
- Note however that for file-scope tagged types we cannot assume
- that such pre-resolution of forward references has taken place.
- A given file-scope tagged type may appear to be incomplete when
- we reach this point, but it may yet be given a full definition
- (at file-scope) later on during compilation. In order to avoid
- generating a premature (and possibly incorrect) set of Dwarf
- DIEs for such (as yet incomplete) file-scope tagged types, we
- generate nothing at all for as-yet incomplete file-scope tagged
- types here unless we are making our special "finalization" pass
- for file-scope things at the very end of compilation. At that
- time, we will certainly know as much about each file-scope tagged
- type as we are ever going to know, so at that point in time, we
- can safely generate correct Dwarf descriptions for these file-
- scope tagged types. */
-
- if (!COMPLETE_TYPE_P (type)
- && (TYPE_CONTEXT (type) == NULL
- || AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
- || TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL)
- && !finalizing)
- {
- /* We don't need to do this for function-local types. */
- if (! decl_function_context (TYPE_STUB_DECL (type)))
- add_incomplete_type (type);
- return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
- }
-
- /* Prevent infinite recursion in cases where the type of some
- member of this type is expressed in terms of this type itself. */
-
- TREE_ASM_WRITTEN (type) = 1;
-
- /* Output a DIE to represent the tagged type itself. */
-
- switch (TREE_CODE (type))
- {
- case ENUMERAL_TYPE:
- output_die (output_enumeration_type_die, type);
- return; /* a special case -- nothing left to do so just return */
-
- case RECORD_TYPE:
- output_die (output_structure_type_die, type);
- break;
-
- case UNION_TYPE:
- case QUAL_UNION_TYPE:
- output_die (output_union_type_die, type);
- break;
-
- default:
- abort (); /* Should never happen. */
- }
-
- /* If this is not an incomplete type, output descriptions of
- each of its members.
-
- Note that as we output the DIEs necessary to represent the
- members of this record or union type, we will also be trying
- to output DIEs to represent the *types* of those members.
- However the `output_type' function (above) will specifically
- avoid generating type DIEs for member types *within* the list
- of member DIEs for this (containing) type except for those
- types (of members) which are explicitly marked as also being
- members of this (containing) type themselves. The g++ front-
- end can force any given type to be treated as a member of some
- other (containing) type by setting the TYPE_CONTEXT of the
- given (member) type to point to the TREE node representing the
- appropriate (containing) type.
- */
-
- if (COMPLETE_TYPE_P (type))
- {
- tree binfo = TYPE_BINFO (type);
-
- /* First output info about the base classes. */
- if (binfo)
- {
- tree bases = BINFO_BASETYPES (binfo);
- tree accesses = BINFO_BASEACCESSES (binfo);
- int n_bases = BINFO_N_BASETYPES (binfo);
- int i;
-
- for (i = 0; i < n_bases; i++)
- {
- tree arg[2];
-
- arg[0] = TREE_VEC_ELT (bases, i);
- arg[1] = (accesses ? TREE_VEC_ELT (accesses, i)
- : access_public_node);
- output_type (BINFO_TYPE (binfo), containing_scope);
- output_die (output_inheritance_die, arg);
- }
- }
-
- ++in_class;
-
- {
- tree normal_member;
-
- /* Now output info about the data members and type members. */
-
- for (normal_member = TYPE_FIELDS (type);
- normal_member;
- normal_member = TREE_CHAIN (normal_member))
- output_decl (normal_member, type);
- }
-
- {
- tree func_member;
-
- /* Now output info about the function members (if any). */
-
- for (func_member = TYPE_METHODS (type);
- func_member;
- func_member = TREE_CHAIN (func_member))
- {
- /* Don't include clones in the member list. */
- if (DECL_ABSTRACT_ORIGIN (func_member))
- continue;
-
- output_decl (func_member, type);
- }
- }
-
- --in_class;
-
- /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
- scopes (at least in C++) so we must now output any nested
- pending types which are local just to this type. */
-
- output_pending_types_for_scope (type);
-
- end_sibling_chain (); /* Terminate member chain. */
- }
-
- break;
-
- case VOID_TYPE:
- case INTEGER_TYPE:
- case REAL_TYPE:
- case COMPLEX_TYPE:
- case BOOLEAN_TYPE:
- case CHAR_TYPE:
- break; /* No DIEs needed for fundamental types. */
-
- case LANG_TYPE: /* No Dwarf representation currently defined. */
- break;
-
- default:
- abort ();
- }
-
- TREE_ASM_WRITTEN (type) = 1;
-}
-
-static void
-output_tagged_type_instantiation (tree type)
-{
- if (type == 0 || type == error_mark_node)
- return;
-
- /* We are going to output a DIE to represent the unqualified version of
- this type (i.e. without any const or volatile qualifiers) so make
- sure that we have the main variant (i.e. the unqualified version) of
- this type now. */
-
- if (type != type_main_variant (type))
- abort ();
-
- if (!TREE_ASM_WRITTEN (type))
- abort ();
-
- switch (TREE_CODE (type))
- {
- case ERROR_MARK:
- break;
-
- case ENUMERAL_TYPE:
- output_die (output_inlined_enumeration_type_die, type);
- break;
-
- case RECORD_TYPE:
- output_die (output_inlined_structure_type_die, type);
- break;
-
- case UNION_TYPE:
- case QUAL_UNION_TYPE:
- output_die (output_inlined_union_type_die, type);
- break;
-
- default:
- abort (); /* Should never happen. */
- }
-}
-
-/* Output a TAG_lexical_block DIE followed by DIEs to represent all of
- the things which are local to the given block. */
-
-static void
-output_block (tree stmt, int depth)
-{
- int must_output_die = 0;
- tree origin;
- enum tree_code origin_code;
-
- /* Ignore blocks never really used to make RTL. */
-
- if (! stmt || ! TREE_USED (stmt)
- || (!TREE_ASM_WRITTEN (stmt) && !BLOCK_ABSTRACT (stmt)))
- return;
-
- /* Determine the "ultimate origin" of this block. This block may be an
- inlined instance of an inlined instance of inline function, so we
- have to trace all of the way back through the origin chain to find
- out what sort of node actually served as the original seed for the
- creation of the current block. */
-
- origin = block_ultimate_origin (stmt);
- origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK;
-
- /* Determine if we need to output any Dwarf DIEs at all to represent this
- block. */
-
- if (origin_code == FUNCTION_DECL)
- /* The outer scopes for inlinings *must* always be represented. We
- generate TAG_inlined_subroutine DIEs for them. (See below.) */
- must_output_die = 1;
- else
- {
- /* In the case where the current block represents an inlining of the
- "body block" of an inline function, we must *NOT* output any DIE
- for this block because we have already output a DIE to represent
- the whole inlined function scope and the "body block" of any
- function doesn't really represent a different scope according to
- ANSI C rules. So we check here to make sure that this block does
- not represent a "body block inlining" before trying to set the
- `must_output_die' flag. */
-
- if (! is_body_block (origin ? origin : stmt))
- {
- /* Determine if this block directly contains any "significant"
- local declarations which we will need to output DIEs for. */
-
- if (debug_info_level > DINFO_LEVEL_TERSE)
- /* We are not in terse mode so *any* local declaration counts
- as being a "significant" one. */
- must_output_die = (BLOCK_VARS (stmt) != NULL);
- else
- {
- tree decl;
-
- /* We are in terse mode, so only local (nested) function
- definitions count as "significant" local declarations. */
-
- for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
- if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
- {
- must_output_die = 1;
- break;
- }
- }
- }
- }
-
- /* It would be a waste of space to generate a Dwarf TAG_lexical_block
- DIE for any block which contains no significant local declarations
- at all. Rather, in such cases we just call `output_decls_for_scope'
- so that any needed Dwarf info for any sub-blocks will get properly
- generated. Note that in terse mode, our definition of what constitutes
- a "significant" local declaration gets restricted to include only
- inlined function instances and local (nested) function definitions. */
-
- if (origin_code == FUNCTION_DECL && BLOCK_ABSTRACT (stmt))
- /* We don't care about an abstract inlined subroutine. */;
- else if (must_output_die)
- {
- output_die ((origin_code == FUNCTION_DECL)
- ? output_inlined_subroutine_die
- : output_lexical_block_die,
- stmt);
- output_decls_for_scope (stmt, depth);
- end_sibling_chain ();
- }
- else
- output_decls_for_scope (stmt, depth);
-}
-
-/* Output all of the decls declared within a given scope (also called
- a `binding contour') and (recursively) all of it's sub-blocks. */
-
-static void
-output_decls_for_scope (tree stmt, int depth)
-{
- /* Ignore blocks never really used to make RTL. */
-
- if (! stmt || ! TREE_USED (stmt))
- return;
-
- /* Output the DIEs to represent all of the data objects, functions,
- typedefs, and tagged types declared directly within this block
- but not within any nested sub-blocks. */
-
- {
- tree decl;
-
- for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
- output_decl (decl, stmt);
- }
-
- output_pending_types_for_scope (stmt);
-
- /* Output the DIEs to represent all sub-blocks (and the items declared
- therein) of this block. */
-
- {
- tree subblocks;
-
- for (subblocks = BLOCK_SUBBLOCKS (stmt);
- subblocks;
- subblocks = BLOCK_CHAIN (subblocks))
- output_block (subblocks, depth + 1);
- }
-}
-
-/* Is this a typedef we can avoid emitting? */
-
-static inline int
-is_redundant_typedef (tree decl)
-{
- if (TYPE_DECL_IS_STUB (decl))
- return 1;
- if (DECL_ARTIFICIAL (decl)
- && DECL_CONTEXT (decl)
- && is_tagged_type (DECL_CONTEXT (decl))
- && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl))) == TYPE_DECL
- && DECL_NAME (decl) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl))))
- /* Also ignore the artificial member typedef for the class name. */
- return 1;
- return 0;
-}
-
-/* Output Dwarf .debug information for a decl described by DECL. */
-
-static void
-output_decl (tree decl, tree containing_scope)
-{
- /* Make a note of the decl node we are going to be working on. We may
- need to give the user the source coordinates of where it appeared in
- case we notice (later on) that something about it looks screwy. */
-
- dwarf_last_decl = decl;
-
- if (TREE_CODE (decl) == ERROR_MARK)
- return;
-
- /* If a structure is declared within an initialization, e.g. as the
- operand of a sizeof, then it will not have a name. We don't want
- to output a DIE for it, as the tree nodes are in the temporary obstack */
-
- if ((TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
- || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
- && ((DECL_NAME (decl) == 0 && TYPE_NAME (TREE_TYPE (decl)) == 0)
- || (TYPE_FIELDS (TREE_TYPE (decl))
- && (TREE_CODE (TYPE_FIELDS (TREE_TYPE (decl))) == ERROR_MARK))))
- return;
-
- /* If this ..._DECL node is marked to be ignored, then ignore it. */
-
- if (DECL_IGNORED_P (decl))
- return;
-
- switch (TREE_CODE (decl))
- {
- case CONST_DECL:
- /* The individual enumerators of an enum type get output when we
- output the Dwarf representation of the relevant enum type itself. */
- break;
-
- case FUNCTION_DECL:
- /* If we are in terse mode, don't output any DIEs to represent
- mere function declarations. Also, if we are conforming
- to the DWARF version 1 specification, don't output DIEs for
- mere function declarations. */
-
- if (DECL_INITIAL (decl) == NULL_TREE)
-#if (DWARF_VERSION > 1)
- if (debug_info_level <= DINFO_LEVEL_TERSE)
-#endif
- break;
-
- /* Before we describe the FUNCTION_DECL itself, make sure that we
- have described its return type. */
-
- output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope);
-
- {
- /* And its containing type. */
- tree origin = decl_class_context (decl);
- if (origin)
- output_type (origin, containing_scope);
- }
-
- /* If we're emitting an out-of-line copy of an inline function,
- set up to refer to the abstract instance emitted from
- dwarfout_deferred_inline_function. */
- if (DECL_INLINE (decl) && ! DECL_ABSTRACT (decl)
- && ! (containing_scope && TYPE_P (containing_scope)))
- set_decl_origin_self (decl);
-
- /* If the following DIE will represent a function definition for a
- function with "extern" linkage, output a special "pubnames" DIE
- label just ahead of the actual DIE. A reference to this label
- was already generated in the .debug_pubnames section sub-entry
- for this function definition. */
-
- if (TREE_PUBLIC (decl))
- {
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
- ASM_OUTPUT_LABEL (asm_out_file, label);
- }
-
- /* Now output a DIE to represent the function itself. */
-
- output_die (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
- ? output_global_subroutine_die
- : output_local_subroutine_die,
- decl);
-
- /* Now output descriptions of the arguments for this function.
- This gets (unnecessarily?) complex because of the fact that
- the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
- cases where there was a trailing `...' at the end of the formal
- parameter list. In order to find out if there was a trailing
- ellipsis or not, we must instead look at the type associated
- with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
- If the chain of type nodes hanging off of this FUNCTION_TYPE node
- ends with a void_type_node then there should *not* be an ellipsis
- at the end. */
-
- /* In the case where we are describing a mere function declaration, all
- we need to do here (and all we *can* do here) is to describe
- the *types* of its formal parameters. */
-
- if (decl != current_function_decl || in_class)
- output_formal_types (TREE_TYPE (decl));
- else
- {
- /* Generate DIEs to represent all known formal parameters. */
-
- tree arg_decls = DECL_ARGUMENTS (decl);
- tree parm;
-
- /* WARNING! Kludge zone ahead! Here we have a special
- hack for svr4 SDB compatibility. Instead of passing the
- current FUNCTION_DECL node as the second parameter (i.e.
- the `containing_scope' parameter) to `output_decl' (as
- we ought to) we instead pass a pointer to our own private
- fake_containing_scope node. That node is a RECORD_TYPE
- node which NO OTHER TYPE may ever actually be a member of.
-
- This pointer will ultimately get passed into `output_type'
- as its `containing_scope' parameter. `Output_type' will
- then perform its part in the hack... i.e. it will pend
- the type of the formal parameter onto the pending_types
- list. Later on, when we are done generating the whole
- sequence of formal parameter DIEs for this function
- definition, we will un-pend all previously pended types
- of formal parameters for this function definition.
-
- This whole kludge prevents any type DIEs from being
- mixed in with the formal parameter DIEs. That's good
- because svr4 SDB believes that the list of formal
- parameter DIEs for a function ends wherever the first
- non-formal-parameter DIE appears. Thus, we have to
- keep the formal parameter DIEs segregated. They must
- all appear (consecutively) at the start of the list of
- children for the DIE representing the function definition.
- Then (and only then) may we output any additional DIEs
- needed to represent the types of these formal parameters.
- */
-
- /*
- When generating DIEs, generate the unspecified_parameters
- DIE instead if we come across the arg "__builtin_va_alist"
- */
-
- for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
- if (TREE_CODE (parm) == PARM_DECL)
- {
- if (DECL_NAME(parm) &&
- !strcmp(IDENTIFIER_POINTER(DECL_NAME(parm)),
- "__builtin_va_alist") )
- output_die (output_unspecified_parameters_die, decl);
- else
- output_decl (parm, fake_containing_scope);
- }
-
- /*
- Now that we have finished generating all of the DIEs to
- represent the formal parameters themselves, force out
- any DIEs needed to represent their types. We do this
- simply by un-pending all previously pended types which
- can legitimately go into the chain of children DIEs for
- the current FUNCTION_DECL.
- */
-
- output_pending_types_for_scope (decl);
-
- /*
- Decide whether we need an unspecified_parameters DIE at the end.
- There are 2 more cases to do this for:
- 1) the ansi ... declaration - this is detectable when the end
- of the arg list is not a void_type_node
- 2) an unprototyped function declaration (not a definition). This
- just means that we have no info about the parameters at all.
- */
-
- {
- tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
-
- if (fn_arg_types)
- {
- /* This is the prototyped case, check for.... */
- if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node)
- output_die (output_unspecified_parameters_die, decl);
- }
- else
- {
- /* This is unprototyped, check for undefined (just declaration). */
- if (!DECL_INITIAL (decl))
- output_die (output_unspecified_parameters_die, decl);
- }
- }
-
- /* Output Dwarf info for all of the stuff within the body of the
- function (if it has one - it may be just a declaration). */
-
- {
- tree outer_scope = DECL_INITIAL (decl);
-
- if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
- {
- /* Note that here, `outer_scope' is a pointer to the outermost
- BLOCK node created to represent a function.
- This outermost BLOCK actually represents the outermost
- binding contour for the function, i.e. the contour in which
- the function's formal parameters and labels get declared.
-
- Curiously, it appears that the front end doesn't actually
- put the PARM_DECL nodes for the current function onto the
- BLOCK_VARS list for this outer scope. (They are strung
- off of the DECL_ARGUMENTS list for the function instead.)
- The BLOCK_VARS list for the `outer_scope' does provide us
- with a list of the LABEL_DECL nodes for the function however,
- and we output DWARF info for those here.
-
- Just within the `outer_scope' there will be a BLOCK node
- representing the function's outermost pair of curly braces,
- and any blocks used for the base and member initializers of
- a C++ constructor function. */
-
- output_decls_for_scope (outer_scope, 0);
-
- /* Finally, force out any pending types which are local to the
- outermost block of this function definition. These will
- all have a TYPE_CONTEXT which points to the FUNCTION_DECL
- node itself. */
-
- output_pending_types_for_scope (decl);
- }
- }
- }
-
- /* Generate a terminator for the list of stuff `owned' by this
- function. */
-
- end_sibling_chain ();
-
- break;
-
- case TYPE_DECL:
- /* If we are in terse mode, don't generate any DIEs to represent
- any actual typedefs. Note that even when we are in terse mode,
- we must still output DIEs to represent those tagged types which
- are used (directly or indirectly) in the specification of either
- a return type or a formal parameter type of some function. */
-
- if (debug_info_level <= DINFO_LEVEL_TERSE)
- if (! TYPE_DECL_IS_STUB (decl)
- || (! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)) && ! in_class))
- return;
-
- /* In the special case of a TYPE_DECL node representing
- the declaration of some type tag, if the given TYPE_DECL is
- marked as having been instantiated from some other (original)
- TYPE_DECL node (e.g. one which was generated within the original
- definition of an inline function) we have to generate a special
- (abbreviated) TAG_structure_type, TAG_union_type, or
- TAG_enumeration-type DIE here. */
-
- if (TYPE_DECL_IS_STUB (decl) && DECL_ABSTRACT_ORIGIN (decl))
- {
- output_tagged_type_instantiation (TREE_TYPE (decl));
- return;
- }
-
- output_type (TREE_TYPE (decl), containing_scope);
-
- if (! is_redundant_typedef (decl))
- /* Output a DIE to represent the typedef itself. */
- output_die (output_typedef_die, decl);
- break;
-
- case LABEL_DECL:
- if (debug_info_level >= DINFO_LEVEL_NORMAL)
- output_die (output_label_die, decl);
- break;
-
- case VAR_DECL:
- /* If we are conforming to the DWARF version 1 specification, don't
- generated any DIEs to represent mere external object declarations. */
-
-#if (DWARF_VERSION <= 1)
- if (DECL_EXTERNAL (decl) && ! TREE_PUBLIC (decl))
- break;
-#endif
-
- /* If we are in terse mode, don't generate any DIEs to represent
- any variable declarations or definitions. */
-
- if (debug_info_level <= DINFO_LEVEL_TERSE)
- break;
-
- /* Output any DIEs that are needed to specify the type of this data
- object. */
-
- output_type (TREE_TYPE (decl), containing_scope);
-
- {
- /* And its containing type. */
- tree origin = decl_class_context (decl);
- if (origin)
- output_type (origin, containing_scope);
- }
-
- /* If the following DIE will represent a data object definition for a
- data object with "extern" linkage, output a special "pubnames" DIE
- label just ahead of the actual DIE. A reference to this label
- was already generated in the .debug_pubnames section sub-entry
- for this data object definition. */
-
- if (TREE_PUBLIC (decl) && ! DECL_ABSTRACT (decl))
- {
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
- ASM_OUTPUT_LABEL (asm_out_file, label);
- }
-
- /* Now output the DIE to represent the data object itself. This gets
- complicated because of the possibility that the VAR_DECL really
- represents an inlined instance of a formal parameter for an inline
- function. */
-
- {
- void (*func) (void *);
- tree origin = decl_ultimate_origin (decl);
-
- if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
- func = output_formal_parameter_die;
- else
- {
- if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
- func = output_global_variable_die;
- else
- func = output_local_variable_die;
- }
- output_die (func, decl);
- }
- break;
-
- case FIELD_DECL:
- /* Ignore the nameless fields that are used to skip bits. */
- if (DECL_NAME (decl) != 0)
- {
- output_type (member_declared_type (decl), containing_scope);
- output_die (output_member_die, decl);
- }
- break;
-
- case PARM_DECL:
- /* Force out the type of this formal, if it was not forced out yet.
- Note that here we can run afoul of a bug in "classic" svr4 SDB.
- It should be able to grok the presence of type DIEs within a list
- of TAG_formal_parameter DIEs, but it doesn't. */
-
- output_type (TREE_TYPE (decl), containing_scope);
- output_die (output_formal_parameter_die, decl);
- break;
-
- case NAMESPACE_DECL:
- /* Ignore for now. */
- break;
-
- default:
- abort ();
- }
-}
-
-/* Output debug information for a function. */
-static void
-dwarfout_function_decl (tree decl)
-{
- dwarfout_file_scope_decl (decl, 0);
-}
-
-/* Debug information for a global DECL. Called from toplev.c after
- compilation proper has finished. */
-static void
-dwarfout_global_decl (tree decl)
-{
- /* Output DWARF information for file-scope tentative data object
- declarations, file-scope (extern) function declarations (which
- had no corresponding body) and file-scope tagged type
- declarations and definitions which have not yet been forced out. */
-
- if (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))
- dwarfout_file_scope_decl (decl, 1);
-}
-
-/* DECL is an inline function, whose body is present, but which is not
- being output at this point. (We're putting that off until we need
- to do it.) */
-static void
-dwarfout_deferred_inline_function (tree decl)
-{
- /* Generate the DWARF info for the "abstract" instance of a function
- which we may later generate inlined and/or out-of-line instances
- of. */
- if ((DECL_INLINE (decl) || DECL_ABSTRACT (decl))
- && ! DECL_ABSTRACT_ORIGIN (decl))
- {
- /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
- DWARF code expects it to be set in this case. Intuitively,
- DECL is the function we just finished defining, so setting
- CURRENT_FUNCTION_DECL is sensible. */
- tree saved_cfd = current_function_decl;
- int was_abstract = DECL_ABSTRACT (decl);
- current_function_decl = decl;
-
- /* Let the DWARF code do its work. */
- set_decl_abstract_flags (decl, 1);
- dwarfout_file_scope_decl (decl, 0);
- if (! was_abstract)
- set_decl_abstract_flags (decl, 0);
-
- /* Reset CURRENT_FUNCTION_DECL. */
- current_function_decl = saved_cfd;
- }
-}
-
-static void
-dwarfout_file_scope_decl (tree decl, int set_finalizing)
-{
- if (TREE_CODE (decl) == ERROR_MARK)
- return;
-
- /* If this ..._DECL node is marked to be ignored, then ignore it. */
-
- if (DECL_IGNORED_P (decl))
- return;
-
- switch (TREE_CODE (decl))
- {
- case FUNCTION_DECL:
-
- /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
- a builtin function. Explicit programmer-supplied declarations of
- these same functions should NOT be ignored however. */
-
- if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
- return;
-
- /* What we would really like to do here is to filter out all mere
- file-scope declarations of file-scope functions which are never
- referenced later within this translation unit (and keep all of
- ones that *are* referenced later on) but we aren't clairvoyant,
- so we have no idea which functions will be referenced in the
- future (i.e. later on within the current translation unit).
- So here we just ignore all file-scope function declarations
- which are not also definitions. If and when the debugger needs
- to know something about these functions, it will have to hunt
- around and find the DWARF information associated with the
- *definition* of the function.
-
- Note that we can't just check `DECL_EXTERNAL' to find out which
- FUNCTION_DECL nodes represent definitions and which ones represent
- mere declarations. We have to check `DECL_INITIAL' instead. That's
- because the C front-end supports some weird semantics for "extern
- inline" function definitions. These can get inlined within the
- current translation unit (an thus, we need to generate DWARF info
- for their abstract instances so that the DWARF info for the
- concrete inlined instances can have something to refer to) but
- the compiler never generates any out-of-lines instances of such
- things (despite the fact that they *are* definitions). The
- important point is that the C front-end marks these "extern inline"
- functions as DECL_EXTERNAL, but we need to generate DWARF for them
- anyway.
-
- Note that the C++ front-end also plays some similar games for inline
- function definitions appearing within include files which also
- contain `#pragma interface' pragmas. */
-
- if (DECL_INITIAL (decl) == NULL_TREE)
- return;
-
- if (TREE_PUBLIC (decl)
- && ! DECL_EXTERNAL (decl)
- && ! DECL_ABSTRACT (decl))
- {
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- /* Output a .debug_pubnames entry for a public function
- defined in this compilation unit. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
- sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
- IDENTIFIER_POINTER (DECL_NAME (decl)));
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
-
- break;
-
- case VAR_DECL:
-
- /* Ignore this VAR_DECL if it refers to a file-scope extern data
- object declaration and if the declaration was never even
- referenced from within this entire compilation unit. We
- suppress these DIEs in order to save space in the .debug section
- (by eliminating entries which are probably useless). Note that
- we must not suppress block-local extern declarations (whether
- used or not) because that would screw-up the debugger's name
- lookup mechanism and cause it to miss things which really ought
- to be in scope at a given point. */
-
- if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
- return;
-
- if (TREE_PUBLIC (decl)
- && ! DECL_EXTERNAL (decl)
- && GET_CODE (DECL_RTL (decl)) == MEM
- && ! DECL_ABSTRACT (decl))
- {
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- if (debug_info_level >= DINFO_LEVEL_NORMAL)
- {
- /* Output a .debug_pubnames entry for a public variable
- defined in this compilation unit. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
- sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
- IDENTIFIER_POINTER (DECL_NAME (decl)));
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
-
- if (DECL_INITIAL (decl) == NULL)
- {
- /* Output a .debug_aranges entry for a public variable
- which is tentatively defined in this compilation unit. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file,
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
- (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
- }
-
- /* If we are in terse mode, don't generate any DIEs to represent
- any variable declarations or definitions. */
-
- if (debug_info_level <= DINFO_LEVEL_TERSE)
- return;
-
- break;
-
- case TYPE_DECL:
- /* Don't bother trying to generate any DIEs to represent any of the
- normal built-in types for the language we are compiling, except
- in cases where the types in question are *not* DWARF fundamental
- types. We make an exception in the case of non-fundamental types
- for the sake of Objective-C (and perhaps C++) because the GNU
- front-ends for these languages may in fact create certain "built-in"
- types which are (for example) RECORD_TYPEs. In such cases, we
- really need to output these (non-fundamental) types because other
- DIEs may contain references to them. */
-
- /* Also ignore language dependent types here, because they are probably
- also built-in types. If we didn't ignore them, then we would get
- references to undefined labels because output_type doesn't support
- them. So, for now, we need to ignore them to avoid assembler
- errors. */
-
- /* ??? This code is different than the equivalent code in dwarf2out.c.
- The dwarf2out.c code is probably more correct. */
-
- if (DECL_SOURCE_LINE (decl) == 0
- && (type_is_fundamental (TREE_TYPE (decl))
- || TREE_CODE (TREE_TYPE (decl)) == LANG_TYPE))
- return;
-
- /* If we are in terse mode, don't generate any DIEs to represent
- any actual typedefs. Note that even when we are in terse mode,
- we must still output DIEs to represent those tagged types which
- are used (directly or indirectly) in the specification of either
- a return type or a formal parameter type of some function. */
-
- if (debug_info_level <= DINFO_LEVEL_TERSE)
- if (! TYPE_DECL_IS_STUB (decl)
- || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
- return;
-
- break;
-
- default:
- return;
- }
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
- finalizing = set_finalizing;
- output_decl (decl, NULL_TREE);
-
- /* NOTE: The call above to `output_decl' may have caused one or more
- file-scope named types (i.e. tagged types) to be placed onto the
- pending_types_list. We have to get those types off of that list
- at some point, and this is the perfect time to do it. If we didn't
- take them off now, they might still be on the list when cc1 finally
- exits. That might be OK if it weren't for the fact that when we put
- types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
- for these types, and that causes them never to be output unless
- `output_pending_types_for_scope' takes them off of the list and un-sets
- their TREE_ASM_WRITTEN flags. */
-
- output_pending_types_for_scope (NULL_TREE);
-
- /* The above call should have totally emptied the pending_types_list
- if this is not a nested function or class. If this is a nested type,
- then the remaining pending_types will be emitted when the containing type
- is handled. */
-
- if (! DECL_CONTEXT (decl))
- {
- if (pending_types != 0)
- abort ();
- }
-
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-}
-
-/* Output a marker (i.e. a label) for the beginning of the generated code
- for a lexical block. */
-
-static void
-dwarfout_begin_block (unsigned int line ATTRIBUTE_UNUSED,
- unsigned int blocknum)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- function_section (current_function_decl);
- sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum);
- ASM_OUTPUT_LABEL (asm_out_file, label);
-}
-
-/* Output a marker (i.e. a label) for the end of the generated code
- for a lexical block. */
-
-static void
-dwarfout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int blocknum)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- function_section (current_function_decl);
- sprintf (label, BLOCK_END_LABEL_FMT, blocknum);
- ASM_OUTPUT_LABEL (asm_out_file, label);
-}
-
-/* Output a marker (i.e. a label) for the point in the generated code where
- the real body of the function begins (after parameters have been moved
- to their home locations). */
-
-static void
-dwarfout_end_prologue (unsigned int line ATTRIBUTE_UNUSED,
- const char *file ATTRIBUTE_UNUSED)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- if (! use_gnu_debug_info_extensions)
- return;
-
- function_section (current_function_decl);
- sprintf (label, BODY_BEGIN_LABEL_FMT, current_function_funcdef_no);
- ASM_OUTPUT_LABEL (asm_out_file, label);
-}
-
-/* Output a marker (i.e. a label) for the point in the generated code where
- the real body of the function ends (just before the epilogue code). */
-
-static void
-dwarfout_end_function (unsigned int line ATTRIBUTE_UNUSED)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- if (! use_gnu_debug_info_extensions)
- return;
- function_section (current_function_decl);
- sprintf (label, BODY_END_LABEL_FMT, current_function_funcdef_no);
- ASM_OUTPUT_LABEL (asm_out_file, label);
-}
-
-/* Output a marker (i.e. a label) for the absolute end of the generated code
- for a function definition. This gets called *after* the epilogue code
- has been generated. */
-
-static void
-dwarfout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED,
- const char *file ATTRIBUTE_UNUSED)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- /* Output a label to mark the endpoint of the code generated for this
- function. */
-
- sprintf (label, FUNC_END_LABEL_FMT, current_function_funcdef_no);
- ASM_OUTPUT_LABEL (asm_out_file, label);
-}
-
-static void
-shuffle_filename_entry (filename_entry *new_zeroth)
-{
- filename_entry temp_entry;
- filename_entry *limit_p;
- filename_entry *move_p;
-
- if (new_zeroth == &filename_table[0])
- return;
-
- temp_entry = *new_zeroth;
-
- /* Shift entries up in the table to make room at [0]. */
-
- limit_p = &filename_table[0];
- for (move_p = new_zeroth; move_p > limit_p; move_p--)
- *move_p = *(move_p-1);
-
- /* Install the found entry at [0]. */
-
- filename_table[0] = temp_entry;
-}
-
-/* Create a new (string) entry for the .debug_sfnames section. */
-
-static void
-generate_new_sfname_entry (void)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SFNAMES_SECTION);
- sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
- ASM_OUTPUT_LABEL (asm_out_file, label);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
- filename_table[0].name
- ? filename_table[0].name
- : "");
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-}
-
-/* Lookup a filename (in the list of filenames that we know about here in
- dwarfout.c) and return its "index". The index of each (known) filename
- is just a unique number which is associated with only that one filename.
- We need such numbers for the sake of generating labels (in the
- .debug_sfnames section) and references to those unique labels (in the
- .debug_srcinfo and .debug_macinfo sections).
-
- If the filename given as an argument is not found in our current list,
- add it to the list and assign it the next available unique index number.
-
- Whatever we do (i.e. whether we find a pre-existing filename or add a new
- one), we shuffle the filename found (or added) up to the zeroth entry of
- our list of filenames (which is always searched linearly). We do this so
- as to optimize the most common case for these filename lookups within
- dwarfout.c. The most common case by far is the case where we call
- lookup_filename to lookup the very same filename that we did a lookup
- on the last time we called lookup_filename. We make sure that this
- common case is fast because such cases will constitute 99.9% of the
- lookups we ever do (in practice).
-
- If we add a new filename entry to our table, we go ahead and generate
- the corresponding entry in the .debug_sfnames section right away.
- Doing so allows us to avoid tickling an assembler bug (present in some
- m68k assemblers) which yields assembly-time errors in cases where the
- difference of two label addresses is taken and where the two labels
- are in a section *other* than the one where the difference is being
- calculated, and where at least one of the two symbol references is a
- forward reference. (This bug could be tickled by our .debug_srcinfo
- entries if we don't output their corresponding .debug_sfnames entries
- before them.) */
-
-static unsigned
-lookup_filename (const char *file_name)
-{
- filename_entry *search_p;
- filename_entry *limit_p = &filename_table[ft_entries];
-
- for (search_p = filename_table; search_p < limit_p; search_p++)
- if (!strcmp (file_name, search_p->name))
- {
- /* When we get here, we have found the filename that we were
- looking for in the filename_table. Now we want to make sure
- that it gets moved to the zero'th entry in the table (if it
- is not already there) so that subsequent attempts to find the
- same filename will find it as quickly as possible. */
-
- shuffle_filename_entry (search_p);
- return filename_table[0].number;
- }
-
- /* We come here whenever we have a new filename which is not registered
- in the current table. Here we add it to the table. */
-
- /* Prepare to add a new table entry by making sure there is enough space
- in the table to do so. If not, expand the current table. */
-
- if (ft_entries == ft_entries_allocated)
- {
- ft_entries_allocated += FT_ENTRIES_INCREMENT;
- filename_table
- = xrealloc (filename_table,
- ft_entries_allocated * sizeof (filename_entry));
- }
-
- /* Initially, add the new entry at the end of the filename table. */
-
- filename_table[ft_entries].number = ft_entries;
- filename_table[ft_entries].name = xstrdup (file_name);
-
- /* Shuffle the new entry into filename_table[0]. */
-
- shuffle_filename_entry (&filename_table[ft_entries]);
-
- if (debug_info_level >= DINFO_LEVEL_NORMAL)
- generate_new_sfname_entry ();
-
- ft_entries++;
- return filename_table[0].number;
-}
-
-static void
-generate_srcinfo_entry (unsigned int line_entry_num, unsigned int files_entry_num)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SRCINFO_SECTION);
- sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL);
- sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, SFNAMES_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-}
-
-static void
-dwarfout_source_line (unsigned int line, const char *filename)
-{
- if (debug_info_level >= DINFO_LEVEL_NORMAL
- /* We can't emit line number info for functions in separate sections,
- because the assembler can't subtract labels in different sections. */
- && DECL_SECTION_NAME (current_function_decl) == NULL_TREE)
- {
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
- static unsigned last_line_entry_num = 0;
- static unsigned prev_file_entry_num = (unsigned) -1;
- unsigned this_file_entry_num;
-
- function_section (current_function_decl);
- sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num);
- ASM_OUTPUT_LABEL (asm_out_file, label);
-
- fputc ('\n', asm_out_file);
-
- if (use_gnu_debug_info_extensions)
- this_file_entry_num = lookup_filename (filename);
- else
- this_file_entry_num = (unsigned) -1;
-
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
- if (this_file_entry_num != prev_file_entry_num)
- {
- char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
- ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
- }
-
- {
- const char *tail = strrchr (filename, '/');
-
- if (tail != NULL)
- filename = tail;
- }
-
- dw2_asm_output_data (4, line, "%s:%u", filename, line);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- if (this_file_entry_num != prev_file_entry_num)
- generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
- prev_file_entry_num = this_file_entry_num;
- }
-}
-
-/* Generate an entry in the .debug_macinfo section. */
-
-static void
-generate_macinfo_entry (unsigned int type, rtx offset, const char *string)
-{
- if (! use_gnu_debug_info_extensions)
- return;
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
- assemble_integer (gen_rtx_PLUS (SImode, GEN_INT (type << 24), offset),
- 4, BITS_PER_UNIT, 1);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, string);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-}
-
-/* Wrapper for toplev.c callback to check debug info level. */
-static void
-dwarfout_start_source_file_check (unsigned int line, const char *filename)
-{
- if (debug_info_level == DINFO_LEVEL_VERBOSE)
- dwarfout_start_source_file (line, filename);
-}
-
-static void
-dwarfout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
- const char *filename)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
- const char *label1, *label2;
-
- sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename));
- label1 = (*label == '*') + label;
- label2 = (*SFNAMES_BEGIN_LABEL == '*') + SFNAMES_BEGIN_LABEL;
- generate_macinfo_entry (MACINFO_start,
- gen_rtx_MINUS (Pmode,
- gen_rtx_SYMBOL_REF (Pmode, label1),
- gen_rtx_SYMBOL_REF (Pmode, label2)),
- "");
-}
-
-/* Wrapper for toplev.c callback to check debug info level. */
-static void
-dwarfout_end_source_file_check (unsigned int lineno)
-{
- if (debug_info_level == DINFO_LEVEL_VERBOSE)
- dwarfout_end_source_file (lineno);
-}
-
-static void
-dwarfout_end_source_file (unsigned int lineno)
-{
- generate_macinfo_entry (MACINFO_resume, GEN_INT (lineno), "");
-}
-
-/* Called from check_newline in c-parse.y. The `buffer' parameter
- contains the tail part of the directive line, i.e. the part which
- is past the initial whitespace, #, whitespace, directive-name,
- whitespace part. */
-
-static void
-dwarfout_define (unsigned int lineno, const char *buffer)
-{
- static int initialized = 0;
-
- if (!initialized)
- {
- dwarfout_start_source_file (0, primary_filename);
- initialized = 1;
- }
- generate_macinfo_entry (MACINFO_define, GEN_INT (lineno), buffer);
-}
-
-/* Called from check_newline in c-parse.y. The `buffer' parameter
- contains the tail part of the directive line, i.e. the part which
- is past the initial whitespace, #, whitespace, directive-name,
- whitespace part. */
-
-static void
-dwarfout_undef (unsigned int lineno, const char *buffer)
-{
- generate_macinfo_entry (MACINFO_undef, GEN_INT (lineno), buffer);
-}
-
-/* Set up for Dwarf output at the start of compilation. */
-
-static void
-dwarfout_init (const char *main_input_filename)
-{
- warning ("support for the DWARF1 debugging format is deprecated");
-
- /* Remember the name of the primary input file. */
-
- primary_filename = main_input_filename;
-
- /* Allocate the initial hunk of the pending_sibling_stack. */
-
- pending_sibling_stack
- = xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
- pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT;
- pending_siblings = 1;
-
- /* Allocate the initial hunk of the filename_table. */
-
- filename_table = xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
- ft_entries_allocated = FT_ENTRIES_INCREMENT;
- ft_entries = 0;
-
- /* Allocate the initial hunk of the pending_types_list. */
-
- pending_types_list = xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
- pending_types_allocated = PENDING_TYPES_INCREMENT;
- pending_types = 0;
-
- /* Create an artificial RECORD_TYPE node which we can use in our hack
- to get the DIEs representing types of formal parameters to come out
- only *after* the DIEs for the formal parameters themselves. */
-
- fake_containing_scope = make_node (RECORD_TYPE);
-
- /* Output a starting label for the .text section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- /* Output a starting label for the .data section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
-#if 0 /* GNU C doesn't currently use .data1. */
- /* Output a starting label for the .data1 section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-#endif
-
- /* Output a starting label for the .rodata section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
-#if 0 /* GNU C doesn't currently use .rodata1. */
- /* Output a starting label for the .rodata1 section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-#endif
-
- /* Output a starting label for the .bss section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- if (debug_info_level >= DINFO_LEVEL_NORMAL)
- {
- if (use_gnu_debug_info_extensions)
- {
- /* Output a starting label and an initial (compilation directory)
- entry for the .debug_sfnames section. The starting label will be
- referenced by the initial entry in the .debug_srcinfo section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SFNAMES_SECTION);
- ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
- {
- const char *pwd = get_src_pwd ();
- char *dirname;
-
- if (!pwd)
- fatal_error ("can't get current directory: %m");
-
- dirname = concat (pwd, "/", NULL);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
- free (dirname);
- }
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
-
- if (debug_info_level >= DINFO_LEVEL_VERBOSE
- && use_gnu_debug_info_extensions)
- {
- /* Output a starting label for the .debug_macinfo section. This
- label will be referenced by the AT_mac_info attribute in the
- TAG_compile_unit DIE. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
- ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
-
- /* Generate the initial entry for the .line section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
- ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- if (use_gnu_debug_info_extensions)
- {
- /* Generate the initial entry for the .debug_srcinfo section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SRCINFO_SECTION);
- ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
-#ifdef DWARF_TIMESTAMPS
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
-#else
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
-#endif
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
-
- /* Generate the initial entry for the .debug_pubnames section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- /* Generate the initial entry for the .debug_aranges section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
- DEBUG_ARANGES_END_LABEL,
- DEBUG_ARANGES_BEGIN_LABEL);
- ASM_OUTPUT_LABEL (asm_out_file, DEBUG_ARANGES_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 1);
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
-
- /* Setup first DIE number == 1. */
- NEXT_DIE_NUM = next_unused_dienum++;
-
- /* Generate the initial DIE for the .debug section. Note that the
- (string) value given in the AT_name attribute of the TAG_compile_unit
- DIE will (typically) be a relative pathname and that this pathname
- should be taken as being relative to the directory from which the
- compiler was invoked when the given (base) source file was compiled. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
- ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL);
- output_die (output_compile_unit_die, (void *) main_input_filename);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- fputc ('\n', asm_out_file);
-}
-
-/* Output stuff that dwarf requires at the end of every file. */
-
-static void
-dwarfout_finish (const char *main_input_filename ATTRIBUTE_UNUSED)
-{
- char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
- retry_incomplete_types ();
- fputc ('\n', asm_out_file);
-
- /* Mark the end of the chain of siblings which represent all file-scope
- declarations in this compilation unit. */
-
- /* The (null) DIE which represents the terminator for the (sibling linked)
- list of file-scope items is *special*. Normally, we would just call
- end_sibling_chain at this point in order to output a word with the
- value `4' and that word would act as the terminator for the list of
- DIEs describing file-scope items. Unfortunately, if we were to simply
- do that, the label that would follow this DIE in the .debug section
- (i.e. `..D2') would *not* be properly aligned (as it must be on some
- machines) to a 4 byte boundary.
-
- In order to force the label `..D2' to get aligned to a 4 byte boundary,
- the trick used is to insert extra (otherwise useless) padding bytes
- into the (null) DIE that we know must precede the ..D2 label in the
- .debug section. The amount of padding required can be anywhere between
- 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
- with the padding) would normally contain the value 4, but now it will
- also have to include the padding bytes, so it will instead have some
- value in the range 4..7.
-
- Fortunately, the rules of Dwarf say that any DIE whose length word
- contains *any* value less than 8 should be treated as a null DIE, so
- this trick works out nicely. Clever, eh? Don't give me any credit
- (or blame). I didn't think of this scheme. I just conformed to it.
- */
-
- output_die (output_padded_null_die, (void *) 0);
- dienum_pop ();
-
- sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
- ASM_OUTPUT_LABEL (asm_out_file, label); /* should be ..D2 */
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- /* Output a terminator label for the .text section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- /* Output a terminator label for the .data section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
-#if 0 /* GNU C doesn't currently use .data1. */
- /* Output a terminator label for the .data1 section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-#endif
-
- /* Output a terminator label for the .rodata section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
-#if 0 /* GNU C doesn't currently use .rodata1. */
- /* Output a terminator label for the .rodata1 section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-#endif
-
- /* Output a terminator label for the .bss section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION_NAME);
- ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- if (debug_info_level >= DINFO_LEVEL_NORMAL)
- {
- /* Output a terminating entry for the .line section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
- ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
- ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
- ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- if (use_gnu_debug_info_extensions)
- {
- /* Output a terminating entry for the .debug_srcinfo section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SRCINFO_SECTION);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
- LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
-
- if (debug_info_level >= DINFO_LEVEL_VERBOSE)
- {
- /* Output terminating entries for the .debug_macinfo section. */
-
- dwarfout_end_source_file (0);
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
-
- /* Generate the terminating entry for the .debug_pubnames section. */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
- ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
- ASM_OUTPUT_POP_SECTION (asm_out_file);
-
- /* Generate the terminating entries for the .debug_aranges section.
-
- Note that we want to do this only *after* we have output the end
- labels (for the various program sections) which we are going to
- refer to here. This allows us to work around a bug in the m68k
- svr4 assembler. That assembler gives bogus assembly-time errors
- if (within any given section) you try to take the difference of
- two relocatable symbols, both of which are located within some
- other section, and if one (or both?) of the symbols involved is
- being forward-referenced. By generating the .debug_aranges
- entries at this late point in the assembly output, we skirt the
- issue simply by avoiding forward-references.
- */
-
- fputc ('\n', asm_out_file);
- ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
-
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
-
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL);
-
-#if 0 /* GNU C doesn't currently use .data1. */
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL,
- DATA1_BEGIN_LABEL);
-#endif
-
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL,
- RODATA_BEGIN_LABEL);
-
-#if 0 /* GNU C doesn't currently use .rodata1. */
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL,
- RODATA1_BEGIN_LABEL);
-#endif
-
- ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL);
- ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL);
-
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
- ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
-
- ASM_OUTPUT_LABEL (asm_out_file, DEBUG_ARANGES_END_LABEL);
- ASM_OUTPUT_POP_SECTION (asm_out_file);
- }
-
- /* There should not be any pending types left at the end. We need
- this now because it may not have been checked on the last call to
- dwarfout_file_scope_decl. */
- if (pending_types != 0)
- abort ();
-}
-
-#endif /* DWARF_DEBUGGING_INFO */
diff --git a/gcc/et-forest.c b/gcc/et-forest.c
index ffdce1d76bd..ea7793f83b3 100644
--- a/gcc/et-forest.c
+++ b/gcc/et-forest.c
@@ -30,638 +30,714 @@ Boston, MA 02111-1307, USA.
#include "et-forest.h"
#include "alloc-pool.h"
-struct et_forest_occurrence;
-typedef struct et_forest_occurrence* et_forest_occurrence_t;
+/* We do not enable this with ENABLE_CHECKING, since it is awfully slow. */
+#undef DEBUG_ET
-/* The ET-forest type. */
-struct et_forest
-{
- /* Linked list of nodes is used to destroy the structure. */
- int nnodes;
- alloc_pool node_pool;
- alloc_pool occur_pool;
-};
+#ifdef DEBUG_ET
+#include "basic-block.h"
+#endif
-/* Single occurrence of node in ET-forest.
- A single node may have multiple occurrences.
- */
-struct et_forest_occurrence
+/* The occurence of a node in the et tree. */
+struct et_occ
{
- /* Parent in the splay-tree. */
- et_forest_occurrence_t parent;
+ struct et_node *of; /* The node. */
+
+ struct et_occ *parent; /* Parent in the splay-tree. */
+ struct et_occ *prev; /* Left son in the splay-tree. */
+ struct et_occ *next; /* Right son in the splay-tree. */
+
+ int depth; /* The depth of the node is the sum of depth
+ fields on the path to the root. */
+ int min; /* The minimum value of the depth in the subtree
+ is obtained by adding sum of depth fields
+ on the path to the root. */
+ struct et_occ *min_occ; /* The occurence in the subtree with the minimal
+ depth. */
+};
- /* Children in the splay-tree. */
- et_forest_occurrence_t left, right;
+static alloc_pool et_nodes;
+static alloc_pool et_occurences;
- /* Counts of vertices in the two splay-subtrees. */
- int count_left, count_right;
+/* Changes depth of OCC to D. */
- /* Next occurrence of this node in the sequence. */
- et_forest_occurrence_t next;
+static inline void
+set_depth (struct et_occ *occ, int d)
+{
+ if (!occ)
+ return;
- /* The node, which this occurrence is of. */
- et_forest_node_t node;
-};
+ occ->min += d - occ->depth;
+ occ->depth = d;
+}
+/* Adds D to the depth of OCC. */
-/* ET-forest node. */
-struct et_forest_node
+static inline void
+set_depth_add (struct et_occ *occ, int d)
{
- et_forest_t forest;
- void *value;
-
- /* First and last occurrence of this node in the sequence. */
- et_forest_occurrence_t first, last;
-};
+ if (!occ)
+ return;
+ occ->min += d;
+ occ->depth += d;
+}
-static et_forest_occurrence_t splay (et_forest_occurrence_t);
-static void remove_all_occurrences (et_forest_t, et_forest_node_t);
-static inline et_forest_occurrence_t find_leftmost_node
- (et_forest_occurrence_t);
-static inline et_forest_occurrence_t find_rightmost_node
- (et_forest_occurrence_t);
-static int calculate_value (et_forest_occurrence_t);
+/* Sets prev field of OCC to P. */
-/* Return leftmost node present in the tree roted by OCC. */
-static inline et_forest_occurrence_t
-find_leftmost_node (et_forest_occurrence_t occ)
+static inline void
+set_prev (struct et_occ *occ, struct et_occ *t)
{
- while (occ->left)
- occ = occ->left;
+#ifdef DEBUG_ET
+ if (occ == t)
+ abort ();
+#endif
- return occ;
+ occ->prev = t;
+ if (t)
+ t->parent = occ;
}
-/* Return rightmost node present in the tree roted by OCC. */
-static inline et_forest_occurrence_t
-find_rightmost_node (et_forest_occurrence_t occ)
+/* Sets next field of OCC to P. */
+
+static inline void
+set_next (struct et_occ *occ, struct et_occ *t)
{
- while (occ->right)
- occ = occ->right;
- return occ;
+#ifdef DEBUG_ET
+ if (occ == t)
+ abort ();
+#endif
+
+ occ->next = t;
+ if (t)
+ t->parent = occ;
}
+/* Recompute minimum for occurence OCC. */
-/* Operation splay for splay tree structure representing occurrences. */
-static et_forest_occurrence_t
-splay (et_forest_occurrence_t node)
+static inline void
+et_recomp_min (struct et_occ *occ)
{
- et_forest_occurrence_t parent;
- et_forest_occurrence_t grandparent;
+ struct et_occ *mson = occ->prev;
- while (1)
- {
- parent = node->parent;
+ if (!mson
+ || (occ->next
+ && mson->min > occ->next->min))
+ mson = occ->next;
- if (! parent)
- return node; /* node == root. */
+ if (mson && mson->min < 0)
+ {
+ occ->min = mson->min + occ->depth;
+ occ->min_occ = mson->min_occ;
+ }
+ else
+ {
+ occ->min = occ->depth;
+ occ->min_occ = occ;
+ }
+}
- grandparent = parent->parent;
+#ifdef DEBUG_ET
+/* Checks whether neighbourhood of OCC seems sane. */
- if (! grandparent)
- break;
+static void
+et_check_occ_sanity (struct et_occ *occ)
+{
+ if (!occ)
+ return;
- /* Now there are four possible combinations: */
+ if (occ->parent == occ)
+ abort ();
- if (node == parent->left)
- {
- if (parent == grandparent->left)
- {
- et_forest_occurrence_t node1, node2;
- int count1, count2;
-
- node1 = node->right;
- count1 = node->count_right;
- node2 = parent->right;
- count2 = parent->count_right;
-
- grandparent->left = node2;
- grandparent->count_left = count2;
- if (node2)
- node2->parent = grandparent;
- parent->left = node1;
- parent->count_left = count1;
- if (node1)
- node1->parent = parent;
- parent->right = grandparent;
- parent->count_right = count2 + grandparent->count_right + 1;
- node->right = parent;
- node->count_right = count1 + parent->count_right + 1;
-
- node->parent = grandparent->parent;
- parent->parent = node;
- grandparent->parent = parent;
-
- if (node->parent)
- {
- if (node->parent->left == grandparent)
- node->parent->left = node;
- else
- node->parent->right = node;
- }
- }
- else
- {
- /* parent == grandparent->right && node == parent->left*/
- et_forest_occurrence_t node1, node2;
- int count1, count2;
-
- node1 = node->left;
- count1 = node->count_left;
- node2 = node->right;
- count2 = node->count_right;
-
- grandparent->right = node1;
- grandparent->count_right = count1;
- if (node1)
- node1->parent = grandparent;
- parent->left = node2;
- parent->count_left = count2;
- if (node2)
- node2->parent = parent;
- node->left = grandparent;
- node->count_left = grandparent->count_left + count1 + 1;
- node->right = parent;
- node->count_right = parent->count_right + count2 + 1;
-
- node->parent = grandparent->parent;
- parent->parent = node;
- grandparent->parent = node;
-
- if (node->parent)
- {
- if (node->parent->left == grandparent)
- node->parent->left = node;
- else
- node->parent->right = node;
- }
- }
- }
- else
- {
- /* node == parent->right. */
- if (parent == grandparent->left)
- {
- et_forest_occurrence_t node1, node2;
- int count1, count2;
-
- node1 = node->left;
- count1 = node->count_left;
- node2 = node->right;
- count2 = node->count_right;
-
- parent->right = node1;
- parent->count_right = count1;
- if (node1)
- node1->parent = parent;
- grandparent->left = node2;
- grandparent->count_left = count2;
- if (node2)
- node2->parent = grandparent;
- node->left = parent;
- node->count_left = parent->count_left + count1 + 1;
- node->right = grandparent;
- node->count_right = grandparent->count_right + count2 + 1;
-
- node->parent = grandparent->parent;
- parent->parent = node;
- grandparent->parent = node;
-
- if (node->parent)
- {
- if (node->parent->left == grandparent)
- node->parent->left = node;
- else
- node->parent->right = node;
- }
- }
- else
- {
- /* parent == grandparent->right && node == parent->right*/
- et_forest_occurrence_t node1, node2;
- int count1, count2;
-
- node1 = node->left;
- count1 = node->count_left;
- node2 = parent->left;
- count2 = parent->count_left;
-
- grandparent->right = node2;
- grandparent->count_right = count2;
- if (node2)
- node2->parent = grandparent;
- parent->right = node1;
- parent->count_right = count1;
- if (node1)
- node1->parent = parent;
- parent->left = grandparent;
- parent->count_left = count2 + grandparent->count_left + 1;
- node->left = parent;
- node->count_left = count1 + parent->count_left + 1;
-
- node->parent = grandparent->parent;
- parent->parent = node;
- grandparent->parent = parent;
-
- if (node->parent)
- {
- if (node->parent->left == grandparent)
- node->parent->left = node;
- else
- node->parent->right = node;
- }
- }
- }
+ if (occ->prev == occ)
+ abort ();
- }
+ if (occ->next == occ)
+ abort ();
- /* parent == root. */
- /* There are two possible combinations: */
+ if (occ->next && occ->next == occ->prev)
+ abort ();
- if (node == parent->left)
+ if (occ->next)
{
- et_forest_occurrence_t node1;
- int count1;
-
- node1 = node->right;
- count1 = node->count_right;
-
- parent->left = node1;
- parent->count_left = count1;
- if (node1)
- node1->parent = parent;
- node->right = parent;
- node->count_right = parent->count_right + 1 + count1;
- node->parent = parent->parent; /* the same as = 0; */
- parent->parent = node;
-
- if (node->parent)
- {
- if (node->parent->left == parent)
- node->parent->left = node;
- else
- node->parent->right = node;
- }
+ if (occ->next == occ->parent)
+ abort ();
+
+ if (occ->next->parent != occ)
+ abort ();
}
- else
+
+ if (occ->prev)
{
- /* node == parent->right. */
- et_forest_occurrence_t node1;
- int count1;
-
- node1 = node->left;
- count1 = node->count_left;
-
- parent->right = node1;
- parent->count_right = count1;
- if (node1)
- node1->parent = parent;
- node->left = parent;
- node->count_left = parent->count_left + 1 + count1;
- node->parent = parent->parent; /* the same as = 0; */
- parent->parent = node;
-
- if (node->parent)
- {
- if (node->parent->left == parent)
- node->parent->left = node;
- else
- node->parent->right = node;
- }
+ if (occ->prev == occ->parent)
+ abort ();
+
+ if (occ->prev->parent != occ)
+ abort ();
}
- return node;
+ if (occ->parent
+ && occ->parent->prev != occ
+ && occ->parent->next != occ)
+ abort ();
}
-/* Remove all occurrences of the given node before destroying the node. */
+/* Checks whether tree rooted at OCC is sane. */
+
static void
-remove_all_occurrences (et_forest_t forest, et_forest_node_t forest_node)
+et_check_sanity (struct et_occ *occ)
{
- et_forest_occurrence_t first = forest_node->first;
- et_forest_occurrence_t last = forest_node->last;
- et_forest_occurrence_t node;
+ et_check_occ_sanity (occ);
+ if (occ->prev)
+ et_check_sanity (occ->prev);
+ if (occ->next)
+ et_check_sanity (occ->next);
+}
- splay (first);
+/* Checks whether tree containing OCC is sane. */
- if (first->left)
- first->left->parent = 0;
- if (first->right)
- first->right->parent = 0;
+static void
+et_check_tree_sanity (struct et_occ *occ)
+{
+ while (occ->parent)
+ occ = occ->parent;
- if (last != first)
- {
- splay (last);
+ et_check_sanity (occ);
+}
- if (last->left)
- last->left->parent = 0;
- if (last->right)
- last->right->parent = 0;
- }
+/* For recording the paths. */
- if (last->right && first->left) /* actually, first->left would suffice. */
- {
- /* Need to join them. */
- et_forest_occurrence_t prev_node, next_node;
-
- prev_node = splay (find_rightmost_node (first->left));
- next_node = splay (find_leftmost_node (last->right));
- /* prev_node and next_node are consecutive occurrences
- of the same node. */
- if (prev_node->next != next_node)
- abort ();
+static int len;
+static void *datas[100000];
+static int depths[100000];
- prev_node->right = next_node->right;
- prev_node->count_right = next_node->count_right;
- prev_node->next = next_node->next;
- if (prev_node->right)
- prev_node->right->parent = prev_node;
+/* Records the path represented by OCC, with depth incremented by DEPTH. */
- if (prev_node->node->last == next_node)
- prev_node->node->last = prev_node;
+static int
+record_path_before_1 (struct et_occ *occ, int depth)
+{
+ int mn, m;
- pool_free (forest->occur_pool, next_node);
+ depth += occ->depth;
+ mn = depth;
+
+ if (occ->prev)
+ {
+ m = record_path_before_1 (occ->prev, depth);
+ if (m < mn)
+ mn = m;
}
- if (first != last)
+ fprintf (stderr, "%d (%d); ", ((basic_block) occ->of->data)->index, depth);
+ depths[len] = depth;
+ datas[len] = occ->of;
+ len++;
+
+ if (occ->next)
{
- node = first->next;
+ m = record_path_before_1 (occ->next, depth);
+ if (m < mn)
+ mn = m;
+ }
- while (node != last)
- {
- et_forest_occurrence_t next_node;
+ if (mn != occ->min + depth - occ->depth)
+ abort ();
- splay (node);
+ return mn;
+}
- if (node->left)
- node->left->parent = 0;
- if (node->right)
- node->right->parent = 0;
+/* Records the path represented by a tree containing OCC. */
- next_node = node->next;
- pool_free (forest->occur_pool, node);
- node = next_node;
- }
- }
+static void
+record_path_before (struct et_occ *occ)
+{
+ while (occ->parent)
+ occ = occ->parent;
- pool_free (forest->occur_pool, first);
- if (first != last)
- pool_free (forest->occur_pool, last);
+ len = 0;
+ record_path_before_1 (occ, 0);
+ fprintf (stderr, "\n");
}
-/* Calculate ET value of the given node. */
-static inline int
-calculate_value (et_forest_occurrence_t node)
+/* Checks whether the path represented by OCC, with depth incremented by DEPTH,
+ was not changed since the last recording. */
+
+static int
+check_path_after_1 (struct et_occ *occ, int depth)
{
- int value = node->count_left;
+ int mn, m;
+
+ depth += occ->depth;
+ mn = depth;
- while (node->parent)
+ if (occ->next)
{
- if (node == node->parent->right)
- value += node->parent->count_left + 1;
+ m = check_path_after_1 (occ->next, depth);
+ if (m < mn)
+ mn = m;
+ }
- node = node->parent;
+ len--;
+ if (depths[len] != depth
+ || datas[len] != occ->of)
+ abort ();
+
+ if (occ->prev)
+ {
+ m = check_path_after_1 (occ->prev, depth);
+ if (m < mn)
+ mn = m;
}
- return value;
+ if (mn != occ->min + depth - occ->depth)
+ abort ();
+
+ return mn;
}
+/* Checks whether the path represented by a tree containing OCC was
+ not changed since the last recording. */
+
+static void
+check_path_after (struct et_occ *occ)
+{
+ while (occ->parent)
+ occ = occ->parent;
+
+ check_path_after_1 (occ, 0);
+ if (len != 0)
+ abort ();
+}
+#endif
+/* Splay the occurence OCC to the root of the tree. */
-/* Create ET-forest structure. */
-et_forest_t
-et_forest_create (void)
+static inline void
+et_splay (struct et_occ *occ)
{
- et_forest_t forest = xmalloc (sizeof (struct et_forest));
+ struct et_occ *f, *gf, *ggf;
+ int occ_depth, f_depth, gf_depth;
+
+#ifdef DEBUG_ET
+ record_path_before (occ);
+ et_check_tree_sanity (occ);
+#endif
+
+ while (occ->parent)
+ {
+ occ_depth = occ->depth;
- forest->nnodes = 0;
- forest->occur_pool = create_alloc_pool ("et_forest_occurrence pool", sizeof (struct et_forest_occurrence), 300);
- forest->node_pool = create_alloc_pool ("et_forest_node pool", sizeof (struct et_forest_node), 300);
- return forest;
-}
+ f = occ->parent;
+ f_depth = f->depth;
+ gf = f->parent;
+ if (!gf)
+ {
+ set_depth_add (occ, f_depth);
+ occ->min_occ = f->min_occ;
+ occ->min = f->min;
-/* Deallocate the structure. */
-void
-et_forest_delete (et_forest_t forest)
+ if (f->prev == occ)
+ {
+ /* zig */
+ set_prev (f, occ->next);
+ set_next (occ, f);
+ set_depth_add (f->prev, occ_depth);
+ }
+ else
+ {
+ /* zag */
+ set_next (f, occ->prev);
+ set_prev (occ, f);
+ set_depth_add (f->next, occ_depth);
+ }
+ set_depth (f, -occ_depth);
+ occ->parent = NULL;
+
+ et_recomp_min (f);
+#ifdef DEBUG_ET
+ et_check_tree_sanity (occ);
+ check_path_after (occ);
+#endif
+ return;
+ }
+
+ gf_depth = gf->depth;
+
+ set_depth_add (occ, f_depth + gf_depth);
+ occ->min_occ = gf->min_occ;
+ occ->min = gf->min;
+
+ ggf = gf->parent;
+
+ if (gf->prev == f)
+ {
+ if (f->prev == occ)
+ {
+ /* zig zig */
+ set_prev (gf, f->next);
+ set_prev (f, occ->next);
+ set_next (occ, f);
+ set_next (f, gf);
+
+ set_depth (f, -occ_depth);
+ set_depth_add (f->prev, occ_depth);
+ set_depth (gf, -f_depth);
+ set_depth_add (gf->prev, f_depth);
+ }
+ else
+ {
+ /* zag zig */
+ set_prev (gf, occ->next);
+ set_next (f, occ->prev);
+ set_prev (occ, f);
+ set_next (occ, gf);
+
+ set_depth (f, -occ_depth);
+ set_depth_add (f->next, occ_depth);
+ set_depth (gf, -occ_depth - f_depth);
+ set_depth_add (gf->prev, occ_depth + f_depth);
+ }
+ }
+ else
+ {
+ if (f->prev == occ)
+ {
+ /* zig zag */
+ set_next (gf, occ->prev);
+ set_prev (f, occ->next);
+ set_prev (occ, gf);
+ set_next (occ, f);
+
+ set_depth (f, -occ_depth);
+ set_depth_add (f->prev, occ_depth);
+ set_depth (gf, -occ_depth - f_depth);
+ set_depth_add (gf->next, occ_depth + f_depth);
+ }
+ else
+ {
+ /* zag zag */
+ set_next (gf, f->prev);
+ set_next (f, occ->prev);
+ set_prev (occ, f);
+ set_prev (f, gf);
+
+ set_depth (f, -occ_depth);
+ set_depth_add (f->next, occ_depth);
+ set_depth (gf, -f_depth);
+ set_depth_add (gf->next, f_depth);
+ }
+ }
+
+ occ->parent = ggf;
+ if (ggf)
+ {
+ if (ggf->prev == gf)
+ ggf->prev = occ;
+ else
+ ggf->next = occ;
+ }
+
+ et_recomp_min (gf);
+ et_recomp_min (f);
+#ifdef DEBUG_ET
+ et_check_tree_sanity (occ);
+#endif
+ }
+
+#ifdef DEBUG_ET
+ et_check_sanity (occ);
+ check_path_after (occ);
+#endif
+}
+
+/* Create a new et tree occurence of NODE. */
+
+static struct et_occ *
+et_new_occ (struct et_node *node)
{
- if (forest->nnodes)
- abort ();
- free_alloc_pool (forest->occur_pool);
- free_alloc_pool (forest->node_pool);
- free (forest);
+ struct et_occ *nw;
+
+ if (!et_occurences)
+ et_occurences = create_alloc_pool ("et_occ pool", sizeof (struct et_occ), 300);
+ nw = pool_alloc (et_occurences);
+
+ nw->of = node;
+ nw->parent = NULL;
+ nw->prev = NULL;
+ nw->next = NULL;
+
+ nw->depth = 0;
+ nw->min_occ = nw;
+ nw->min = 0;
+
+ return nw;
}
-/* Create new node with VALUE and return the edge.
- Return NULL when memory allocation failed. */
-et_forest_node_t
-et_forest_add_node (et_forest_t forest, void *value)
+/* Create a new et tree containing DATA. */
+
+struct et_node *
+et_new_tree (void *data)
{
- /* Create node with one occurrence. */
- et_forest_node_t node;
- et_forest_occurrence_t occ;
-
- node = pool_alloc (forest->node_pool);
- occ = pool_alloc (forest->occur_pool);
-
- node->first = node->last = occ;
- node->value = value;
- forest->nnodes++;
-
- occ->node = node;
- occ->left = occ->right = occ->parent = 0;
- occ->next = 0;
- occ->count_left = occ->count_right = 0;
- return node;
+ struct et_node *nw;
+
+ if (!et_nodes)
+ et_nodes = create_alloc_pool ("et_node pool", sizeof (struct et_node), 300);
+ nw = pool_alloc (et_nodes);
+
+ nw->data = data;
+ nw->father = NULL;
+ nw->left = NULL;
+ nw->right = NULL;
+ nw->son = NULL;
+
+ nw->rightmost_occ = et_new_occ (nw);
+ nw->parent_occ = NULL;
+
+ return nw;
}
-/* Add new edge to the tree, return 1 if successful.
- 0 indicates that creation of the edge will close the cycle in graph. */
-int
-et_forest_add_edge (et_forest_t forest ATTRIBUTE_UNUSED,
- et_forest_node_t parent_node, et_forest_node_t child_node)
+/* Releases et tree T. */
+
+void
+et_free_tree (struct et_node *t)
{
- et_forest_occurrence_t new_occ, parent_occ, child_occ;
+ while (t->son)
+ et_split (t->son);
- if (! parent_node || ! child_node)
- abort ();
+ if (t->father)
+ et_split (t);
- parent_occ = parent_node->first;
- child_occ = child_node->first;
-
- splay (parent_occ);
- splay (child_occ);
-
- if (parent_occ->parent)
- return 0; /* Both child and parent are in the same tree. */
-
- if (child_occ->left)
- abort (); /* child must be root of its containing tree. */
-
- new_occ = pool_alloc (forest->occur_pool);
-
- new_occ->node = parent_node;
- new_occ->left = child_occ;
- new_occ->count_left = child_occ->count_right + 1; /* count_left is 0. */
- new_occ->right = parent_occ->right;
- new_occ->count_right = parent_occ->count_right;
- new_occ->parent = parent_occ;
- new_occ->next = parent_occ->next;
- child_occ->parent = new_occ;
- parent_occ->right = new_occ;
- parent_occ->count_right = new_occ->count_left + new_occ->count_right + 1;
- parent_occ->next = new_occ;
- if (new_occ->right)
- new_occ->right->parent = new_occ;
-
- if (parent_node->last == parent_occ)
- parent_node->last = new_occ;
- return 1;
+ pool_free (et_occurences, t->rightmost_occ);
+ pool_free (et_nodes, t);
}
-/* Remove NODE from the tree and all connected edges. */
+/* Sets father of et tree T to FATHER. */
+
void
-et_forest_remove_node (et_forest_t forest, et_forest_node_t node)
+et_set_father (struct et_node *t, struct et_node *father)
{
- remove_all_occurrences (forest, node);
- forest->nnodes--;
+ struct et_node *left, *right;
+ struct et_occ *rmost, *left_part, *new_f_occ, *p;
- pool_free (forest->node_pool, node);
-}
+ /* Update the path represented in the splay tree. */
+ new_f_occ = et_new_occ (father);
-/* Remove edge from the tree, return 1 if successful,
- 0 indicates nonexisting edge. */
-int
-et_forest_remove_edge (et_forest_t forest ATTRIBUTE_UNUSED,
- et_forest_node_t parent_node,
- et_forest_node_t child_node)
-{
- et_forest_occurrence_t parent_pre_occ, parent_post_occ;
+ rmost = father->rightmost_occ;
+ et_splay (rmost);
- splay (child_node->first);
+ left_part = rmost->prev;
- if (! child_node->first->left)
- return 0;
+ p = t->rightmost_occ;
+ et_splay (p);
- parent_pre_occ = find_rightmost_node (child_node->first->left);
- if (parent_pre_occ->node != parent_node)
- abort ();
+ set_prev (new_f_occ, left_part);
+ set_next (new_f_occ, p);
+
+ p->depth++;
+ p->min++;
+ et_recomp_min (new_f_occ);
- splay (parent_pre_occ);
- parent_pre_occ->right->parent = 0;
+ set_prev (rmost, new_f_occ);
- parent_post_occ = parent_pre_occ->next;
- splay (parent_post_occ);
+ if (new_f_occ->min + rmost->depth < rmost->min)
+ {
+ rmost->min = new_f_occ->min + rmost->depth;
+ rmost->min_occ = new_f_occ->min_occ;
+ }
- parent_post_occ->left->parent = 0;
+ t->parent_occ = new_f_occ;
- parent_pre_occ->right = parent_post_occ->right;
- parent_pre_occ->count_right = parent_post_occ->count_right;
- if (parent_post_occ->right)
- parent_post_occ->right->parent = parent_pre_occ;
+ /* Update the tree. */
+ t->father = father;
+ right = father->son;
+ if (right)
+ left = right->left;
+ else
+ left = right = t;
- parent_pre_occ->next = parent_post_occ->next;
+ left->right = t;
+ right->left = t;
+ t->left = left;
+ t->right = right;
- if (parent_post_occ == parent_node->last)
- parent_node->last = parent_pre_occ;
+ father->son = t;
- pool_free (forest->occur_pool, parent_post_occ);
- return 1;
+#ifdef DEBUG_ET
+ et_check_tree_sanity (rmost);
+ record_path_before (rmost);
+#endif
}
-/* Return the parent of the NODE if any, NULL otherwise. */
-et_forest_node_t
-et_forest_parent (et_forest_t forest ATTRIBUTE_UNUSED, et_forest_node_t node)
+/* Splits the edge from T to its father. */
+
+void
+et_split (struct et_node *t)
{
- splay (node->first);
+ struct et_node *father = t->father;
+ struct et_occ *r, *l, *rmost, *p_occ;
- if (node->first->left)
- return find_rightmost_node (node->first->left)->node;
- else
- return 0;
-}
+ /* Update the path represented by the splay tree. */
+ rmost = t->rightmost_occ;
+ et_splay (rmost);
+ for (r = rmost->next; r->prev; r = r->prev)
+ continue;
+ et_splay (r);
-/* Return nearest common ancestor of NODE1 and NODE2.
- Return NULL of they are in different trees. */
-et_forest_node_t
-et_forest_common_ancestor (et_forest_t forest ATTRIBUTE_UNUSED,
- et_forest_node_t node1, et_forest_node_t node2)
-{
- int value1, value2, max_value;
- et_forest_node_t ancestor;
+ r->prev->parent = NULL;
+ p_occ = t->parent_occ;
+ et_splay (p_occ);
+ t->parent_occ = NULL;
- if (node1 == node2)
- return node1;
+ l = p_occ->prev;
+ p_occ->next->parent = NULL;
- if (! node1 || ! node2)
- abort ();
+ set_prev (r, l);
- splay (node1->first);
- splay (node2->first);
+ et_recomp_min (r);
- if (! node1->first->parent) /* The two vertices are in different trees. */
- return 0;
+ et_splay (rmost);
+ rmost->depth = 0;
+ rmost->min = 0;
- value2 = calculate_value (node2->first);
- value1 = calculate_value (node1->first);
+ pool_free (et_occurences, p_occ);
- if (value1 < value2)
+ /* Update the tree. */
+ if (father->son == t)
+ father->son = t->right;
+ if (father->son == t)
+ father->son = NULL;
+ else
{
- ancestor = node1;
- max_value = value2;
+ t->left->right = t->right;
+ t->right->left = t->left;
+ }
+ t->left = t->right = NULL;
+ t->father = NULL;
+
+#ifdef DEBUG_ET
+ et_check_tree_sanity (rmost);
+ record_path_before (rmost);
+
+ et_check_tree_sanity (r);
+ record_path_before (r);
+#endif
+}
+
+/* Finds the nearest common ancestor of the nodes N1 and N2. */
+
+struct et_node *
+et_nca (struct et_node *n1, struct et_node *n2)
+{
+ struct et_occ *o1 = n1->rightmost_occ, *o2 = n2->rightmost_occ, *om;
+ struct et_occ *l, *r, *ret;
+ int mn;
+
+ if (n1 == n2)
+ return n1;
+
+ et_splay (o1);
+ l = o1->prev;
+ r = o1->next;
+ if (l)
+ l->parent = NULL;
+ if (r)
+ r->parent = NULL;
+ et_splay (o2);
+
+ if (l == o2 || (l && l->parent != NULL))
+ {
+ ret = o2->next;
+
+ set_prev (o1, o2);
+ if (r)
+ r->parent = o1;
}
else
{
- ancestor = node2;
- max_value = value1;
+ ret = o2->prev;
+
+ set_next (o1, o2);
+ if (l)
+ l->parent = o1;
}
- while (calculate_value (ancestor->last) < max_value)
+ if (0 < o2->depth)
{
- /* Find parent node. */
- splay (ancestor->first);
- ancestor = find_rightmost_node (ancestor->first->left) ->node;
+ om = o1;
+ mn = o1->depth;
+ }
+ else
+ {
+ om = o2;
+ mn = o2->depth + o1->depth;
}
- return ancestor;
-}
+#ifdef DEBUG_ET
+ et_check_tree_sanity (o2);
+#endif
-/* Return the value pointer of node set during it's creation. */
-void *
-et_forest_node_value (et_forest_t forest ATTRIBUTE_UNUSED,
- et_forest_node_t node)
-{
- /* Alloc threading NULL as a special node of the forest. */
- if (!node)
- return NULL;
- return node->value;
+ if (ret && ret->min + o1->depth + o2->depth < mn)
+ return ret->min_occ->of;
+ else
+ return om->of;
}
-/* Find all sons of NODE and store them into ARRAY allocated by the caller.
- Return number of nodes found. */
-int
-et_forest_enumerate_sons (et_forest_t forest ATTRIBUTE_UNUSED,
- et_forest_node_t node, et_forest_node_t *array)
+/* Checks whether the node UP is an ancestor of the node DOWN. */
+
+bool
+et_below (struct et_node *down, struct et_node *up)
{
- int n = 0;
- et_forest_occurrence_t occ = node->first, stop = node->last, occ1;
+ struct et_occ *u = up->rightmost_occ, *d = down->rightmost_occ;
+ struct et_occ *l, *r;
+
+ if (up == down)
+ return true;
+
+ et_splay (u);
+ l = u->prev;
+ r = u->next;
+
+ if (!l)
+ return false;
+
+ l->parent = NULL;
+
+ if (r)
+ r->parent = NULL;
- /* Parent is the rightmost node of the left successor.
- Look for all occurrences having no right successor
- and lookup the sons. */
- while (occ != stop)
+ et_splay (d);
+
+ if (l == d || l->parent != NULL)
{
- splay (occ);
- if (occ->right)
- {
- occ1 = find_leftmost_node (occ->right);
- if (occ1->node->first == occ1)
- array[n++] = occ1->node;
- }
- occ = occ->next;
+ if (r)
+ r->parent = u;
+ set_prev (u, d);
+#ifdef DEBUG_ET
+ et_check_tree_sanity (u);
+#endif
}
- return n;
+ else
+ {
+ l->parent = u;
+
+ /* In case O1 and O2 are in two different trees, we must just restore the
+ original state. */
+ if (r && r->parent != NULL)
+ set_next (u, d);
+ else
+ set_next (u, r);
+
+#ifdef DEBUG_ET
+ et_check_tree_sanity (u);
+#endif
+ return false;
+ }
+
+ if (0 >= d->depth)
+ return false;
+
+ return !d->next || d->next->min + d->depth >= 0;
}
diff --git a/gcc/et-forest.h b/gcc/et-forest.h
index f646d59b910..833146d6147 100644
--- a/gcc/et-forest.h
+++ b/gcc/et-forest.h
@@ -55,26 +55,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
extern "C" {
#endif /* __cplusplus */
-typedef struct et_forest *et_forest_t;
-typedef struct et_forest_node *et_forest_node_t;
-
-extern et_forest_t et_forest_create (void);
-
-extern void et_forest_delete (et_forest_t);
-
-extern et_forest_node_t et_forest_add_node (et_forest_t, void *);
-extern int et_forest_add_edge (et_forest_t, et_forest_node_t,
- et_forest_node_t);
-extern void et_forest_remove_node (et_forest_t, et_forest_node_t);
-extern int et_forest_remove_edge (et_forest_t, et_forest_node_t,
- et_forest_node_t);
-extern et_forest_node_t et_forest_parent (et_forest_t, et_forest_node_t);
-extern et_forest_node_t et_forest_common_ancestor (et_forest_t,
- et_forest_node_t,
- et_forest_node_t);
-extern void * et_forest_node_value (et_forest_t, et_forest_node_t);
-extern int et_forest_enumerate_sons (et_forest_t, et_forest_node_t,
- et_forest_node_t *);
+/* The node representing the node in an et tree. */
+struct et_node
+{
+ void *data; /* The data represented by the node. */
+
+ int dfs_num_in, dfs_num_out; /* Number of the node in the dfs ordering. */
+
+ struct et_node *father; /* Father of the node. */
+ struct et_node *son; /* The first of the sons of the node. */
+ struct et_node *left;
+ struct et_node *right; /* The brothers of the node. */
+
+ struct et_occ *rightmost_occ; /* The rightmost occurence. */
+ struct et_occ *parent_occ; /* The occurence of the parent node. */
+};
+
+struct et_node *et_new_tree (void *data);
+void et_free_tree (struct et_node *);
+void et_set_father (struct et_node *, struct et_node *);
+void et_split (struct et_node *);
+struct et_node *et_nca (struct et_node *, struct et_node *);
+bool et_below (struct et_node *, struct et_node *);
#ifdef __cplusplus
}
diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog
index 99a666f9d35..3dcc5628f70 100644
--- a/gcc/f/ChangeLog
+++ b/gcc/f/ChangeLog
@@ -1,3 +1,14 @@
+2003-12-29 Roger Sayle <roger@eyesopen.com>
+
+ PR fortran/12632
+ * com.c (ffecom_subscript_check_): Take as an extra argument the
+ (possibly NULL) decl of the array. Don't create unnecessary tree
+ nodes if the array index is known to be safe at compile-time.
+ If the array index is unsafe, force the array decl into memory to
+ avoid RTL expansion problems.
+ (ffecom_array_ref_): Update calls to ffecom_subscript_check_.
+ (ffecom_char_args_x_): Likewise.
+
2003-12-06 Kelley Cook <kcook@gcc.gnu.org>
* Make-lang.in (G77_CROSS_NAME): Delete.
diff --git a/gcc/f/com.c b/gcc/f/com.c
index 535ddbb87e8..a64ef86b172 100644
--- a/gcc/f/com.c
+++ b/gcc/f/com.c
@@ -638,15 +638,16 @@ static GTY(()) tree shadowed_labels;
/* Return the subscript expression, modified to do range-checking.
- `array' is the array to be checked against.
+ `array' is the array type to be checked against.
`element' is the subscript expression to check.
`dim' is the dimension number (starting at 0).
`total_dims' is the total number of dimensions (0 for CHARACTER substring).
+ `item' is the array decl or NULL_TREE.
*/
static tree
ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims,
- const char *array_name)
+ const char *array_name, tree item)
{
tree low = TYPE_MIN_VALUE (TYPE_DOMAIN (array));
tree high = TYPE_MAX_VALUE (TYPE_DOMAIN (array));
@@ -713,6 +714,10 @@ ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims,
}
}
+ /* If the array index is safe at compile-time, return element. */
+ if (integer_nonzerop (cond))
+ return element;
+
{
int len;
char *proc;
@@ -807,13 +812,10 @@ ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims,
TREE_SIDE_EFFECTS (die) = 1;
die = convert (void_type_node, die);
- element = ffecom_3 (COND_EXPR,
- TREE_TYPE (element),
- cond,
- element,
- die);
+ if (integer_zerop (cond) && item)
+ ffe_mark_addressable (item);
- return element;
+ return ffecom_3 (COND_EXPR, TREE_TYPE (element), cond, element, die);
}
/* Return the computed element of an array reference.
@@ -899,7 +901,7 @@ ffecom_arrayref_ (tree item, ffebld expr, int want_ptr)
element = ffecom_expr_ (dims[i], NULL, NULL, NULL, FALSE, TRUE);
if (flag_bounds_check)
element = ffecom_subscript_check_ (array, element, i, total_dims,
- array_name);
+ array_name, item);
if (element == error_mark_node)
return element;
@@ -945,7 +947,7 @@ ffecom_arrayref_ (tree item, ffebld expr, int want_ptr)
element = ffecom_expr_ (dims[i], NULL, NULL, NULL, FALSE, TRUE);
if (flag_bounds_check)
element = ffecom_subscript_check_ (array, element, i, total_dims,
- array_name);
+ array_name, item);
if (element == error_mark_node)
return element;
@@ -2037,7 +2039,7 @@ ffecom_char_args_x_ (tree *xitem, tree *length, ffebld expr, bool with_null)
end_tree = ffecom_expr (end);
if (flag_bounds_check)
end_tree = ffecom_subscript_check_ (array, end_tree, 1, 0,
- char_name);
+ char_name, NULL_TREE);
end_tree = convert (ffecom_f2c_ftnlen_type_node,
end_tree);
@@ -2055,7 +2057,7 @@ ffecom_char_args_x_ (tree *xitem, tree *length, ffebld expr, bool with_null)
start_tree = ffecom_expr (start);
if (flag_bounds_check)
start_tree = ffecom_subscript_check_ (array, start_tree, 0, 0,
- char_name);
+ char_name, NULL_TREE);
start_tree = convert (ffecom_f2c_ftnlen_type_node,
start_tree);
@@ -2088,7 +2090,7 @@ ffecom_char_args_x_ (tree *xitem, tree *length, ffebld expr, bool with_null)
end_tree = ffecom_expr (end);
if (flag_bounds_check)
end_tree = ffecom_subscript_check_ (array, end_tree, 1, 0,
- char_name);
+ char_name, NULL_TREE);
end_tree = convert (ffecom_f2c_ftnlen_type_node,
end_tree);
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 3da0ebf6f46..7a939c49666 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7864,9 +7864,17 @@ fold (tree expr)
/* Pedantic ANSI C says that a conditional expression is never an lvalue,
so all simple results must be passed through pedantic_non_lvalue. */
if (TREE_CODE (arg0) == INTEGER_CST)
- return pedantic_non_lvalue
- (TREE_OPERAND (t, (integer_zerop (arg0) ? 2 : 1)));
- else if (operand_equal_p (arg1, TREE_OPERAND (expr, 2), 0))
+ {
+ tem = TREE_OPERAND (t, (integer_zerop (arg0) ? 2 : 1));
+ /* Only optimize constant conditions when the selected branch
+ has the same type as the COND_EXPR. This avoids optimizing
+ away "c ? x : throw", where the throw has a void type. */
+ if (! VOID_TYPE_P (TREE_TYPE (tem))
+ || VOID_TYPE_P (TREE_TYPE (t)))
+ return pedantic_non_lvalue (tem);
+ return t;
+ }
+ if (operand_equal_p (arg1, TREE_OPERAND (expr, 2), 0))
return pedantic_omit_one_operand (type, arg1, arg0);
/* If we have A op B ? A : C, we may be able to convert this to a
diff --git a/gcc/function.c b/gcc/function.c
index 6eb44aeec34..1da182af4dc 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -4740,9 +4740,28 @@ assign_parms (tree fndecl)
if (REG_P (parmreg))
{
+ unsigned int regno = REGNO (parmreg);
+
emit_group_store (parmreg, entry_parm, TREE_TYPE (parm),
int_size_in_bytes (TREE_TYPE (parm)));
SET_DECL_RTL (parm, parmreg);
+
+ if (regno >= max_parm_reg)
+ {
+ rtx *new;
+ int old_max_parm_reg = max_parm_reg;
+
+ /* It's slow to expand this one register at a time,
+ but it's also rare and we need max_parm_reg to be
+ precisely correct. */
+ max_parm_reg = regno + 1;
+ new = ggc_realloc (parm_reg_stack_loc,
+ max_parm_reg * sizeof (rtx));
+ memset (new + old_max_parm_reg, 0,
+ (max_parm_reg - old_max_parm_reg) * sizeof (rtx));
+ parm_reg_stack_loc = new;
+ parm_reg_stack_loc[regno] = stack_parm;
+ }
}
}
@@ -6389,8 +6408,6 @@ allocate_struct_function (tree fndecl)
DECL_SAVED_INSNS (fndecl) = cfun;
cfun->decl = fndecl;
- current_function_name = (*lang_hooks.decl_printable_name) (fndecl, 2);
-
result = DECL_RESULT (fndecl);
if (aggregate_value_p (result, fndecl))
{
diff --git a/gcc/function.h b/gcc/function.h
index 3f011d700c3..44fcb3fc378 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -183,9 +183,6 @@ struct function GTY(())
/* For function.c. */
- /* Name of this function. */
- const char *name;
-
/* Points to the FUNCTION_DECL of this function. */
tree decl;
@@ -535,7 +532,6 @@ extern int virtuals_instantiated;
extern int trampolines_created;
/* For backward compatibility... eventually these should all go away. */
-#define current_function_name (cfun->name)
#define current_function_pops_args (cfun->pops_args)
#define current_function_returns_struct (cfun->returns_struct)
#define current_function_returns_pcc_struct (cfun->returns_pcc_struct)
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 321ffa396f8..bc6d4c4235b 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -677,7 +677,7 @@ proper position among the other output files. */
%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
%(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
%{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
- %{static:} %{L*} %(link_libgcc) %o %{fprofile-arcs:-lgcov}\
+ %{static:} %{L*} %(link_libgcc) %o %{fprofile-arcs|fprofile-generate:-lgcov}\
%{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\
%{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
#endif
diff --git a/gcc/gcse.c b/gcc/gcse.c
index b52a083d417..cf845af0da7 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -161,6 +161,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "basic-block.h"
#include "output.h"
#include "function.h"
+#include "langhooks.h"
#include "expr.h"
#include "except.h"
#include "ggc.h"
@@ -855,7 +856,8 @@ gcse_main (rtx f, FILE *file)
if (file)
{
fprintf (file, "GCSE of %s: %d basic blocks, ",
- current_function_name, n_basic_blocks);
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ n_basic_blocks);
fprintf (file, "%d pass%s, %d bytes\n\n",
pass, pass > 1 ? "es" : "", max_pass_bytes);
}
@@ -3614,7 +3616,8 @@ one_classic_gcse_pass (int pass)
{
fprintf (gcse_file, "\n");
fprintf (gcse_file, "GCSE of %s, pass %d: %d bytes needed, %d substs,",
- current_function_name, pass, bytes_used, gcse_subst_count);
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ pass, bytes_used, gcse_subst_count);
fprintf (gcse_file, "%d insns created\n", gcse_create_count);
}
@@ -4686,7 +4689,8 @@ one_cprop_pass (int pass, int cprop_jumps, int bypass_jumps)
if (gcse_file)
{
fprintf (gcse_file, "CPROP of %s, pass %d: %d bytes needed, ",
- current_function_name, pass, bytes_used);
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ pass, bytes_used);
fprintf (gcse_file, "%d const props, %d copy props\n\n",
const_prop_count, copy_prop_count);
}
@@ -5788,7 +5792,8 @@ one_pre_gcse_pass (int pass)
if (gcse_file)
{
fprintf (gcse_file, "\nPRE GCSE of %s, pass %d: %d bytes needed, ",
- current_function_name, pass, bytes_used);
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ pass, bytes_used);
fprintf (gcse_file, "%d substs, %d insns created\n",
gcse_subst_count, gcse_create_count);
}
@@ -6182,9 +6187,6 @@ static sbitmap *hoist_vbeout;
/* Hoistable expressions. */
static sbitmap *hoist_exprs;
-/* Dominator bitmaps. */
-dominance_info dominators;
-
/* ??? We could compute post dominators and run this algorithm in
reverse to perform tail merging, doing so would probably be
more effective than the tail merging code in jump.c.
@@ -6221,7 +6223,7 @@ free_code_hoist_mem (void)
sbitmap_vector_free (hoist_exprs);
sbitmap_vector_free (transpout);
- free_dominance_info (dominators);
+ free_dominance_info (CDI_DOMINATORS);
}
/* Compute the very busy expressions at entry/exit from each block.
@@ -6270,7 +6272,7 @@ compute_code_hoist_data (void)
compute_local_properties (transp, comp, antloc, &expr_hash_table);
compute_transpout ();
compute_code_hoist_vbeinout ();
- dominators = calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_DOMINATORS);
if (gcse_file)
fprintf (gcse_file, "\n");
}
@@ -6362,7 +6364,7 @@ hoist_code (void)
int found = 0;
int insn_inserted_p;
- domby_len = get_dominated_by (dominators, bb, &domby);
+ domby_len = get_dominated_by (CDI_DOMINATORS, bb, &domby);
/* Examine each expression that is very busy at the exit of this
block. These are the potentially hoistable expressions. */
for (i = 0; i < hoist_vbeout[bb->index]->n_bits; i++)
@@ -8020,7 +8022,8 @@ bypass_jumps (FILE *file)
if (file)
{
fprintf (file, "BYPASS of %s: %d basic blocks, ",
- current_function_name, n_basic_blocks);
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ n_basic_blocks);
fprintf (file, "%d bytes\n\n", bytes_used);
}
diff --git a/gcc/graph.c b/gcc/graph.c
index d82dd917ce9..483cc7e35a1 100644
--- a/gcc/graph.c
+++ b/gcc/graph.c
@@ -25,9 +25,11 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "tm.h"
#include "rtl.h"
+#include "tree.h"
#include "flags.h"
#include "output.h"
#include "function.h"
+#include "langhooks.h"
#include "hard-reg-set.h"
#include "basic-block.h"
#include "toplev.h"
@@ -55,7 +57,8 @@ start_fct (FILE *fp)
case vcg:
fprintf (fp, "\
graph: { title: \"%s\"\nfolding: 1\nhidden: 2\nnode: { title: \"%s.0\" }\n",
- current_function_name, current_function_name);
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2));
break;
case no_graph:
break;
@@ -71,7 +74,8 @@ start_bb (FILE *fp, int bb)
fprintf (fp, "\
graph: {\ntitle: \"%s.BB%d\"\nfolding: 1\ncolor: lightblue\n\
label: \"basic block %d",
- current_function_name, bb, bb);
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ bb, bb);
break;
case no_graph:
break;
@@ -113,8 +117,9 @@ node_data (FILE *fp, rtx tmp_rtx)
case vcg:
fprintf (fp, "\
edge: { sourcename: \"%s.0\" targetname: \"%s.%d\" }\n",
- current_function_name,
- current_function_name, XINT (tmp_rtx, 0));
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ XINT (tmp_rtx, 0));
break;
case no_graph:
break;
@@ -126,7 +131,8 @@ edge: { sourcename: \"%s.0\" targetname: \"%s.%d\" }\n",
case vcg:
fprintf (fp, "node: {\n title: \"%s.%d\"\n color: %s\n \
label: \"%s %d\n",
- current_function_name, XINT (tmp_rtx, 0),
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ XINT (tmp_rtx, 0),
GET_CODE (tmp_rtx) == NOTE ? "lightgrey"
: GET_CODE (tmp_rtx) == INSN ? "green"
: GET_CODE (tmp_rtx) == JUMP_INSN ? "darkgreen"
@@ -178,8 +184,11 @@ draw_edge (FILE *fp, int from, int to, int bb_edge, int class)
color = "color: green ";
fprintf (fp,
"edge: { sourcename: \"%s.%d\" targetname: \"%s.%d\" %s",
- current_function_name, from,
- current_function_name, to, color);
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ from,
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2),
+ to,
+ color);
if (class)
fprintf (fp, "class: %d ", class);
fputs ("}\n", fp);
@@ -209,7 +218,7 @@ end_fct (FILE *fp)
{
case vcg:
fprintf (fp, "node: { title: \"%s.999999\" label: \"END\" }\n}\n",
- current_function_name);
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2));
break;
case no_graph:
break;
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 24c8fd8ef73..2b10e18628e 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -84,9 +84,6 @@ static int cond_exec_changed_p;
/* True if life data ok at present. */
static bool life_data_ok;
-/* The post-dominator relation on the original block numbers. */
-static dominance_info post_dominators;
-
/* Forward references. */
static int count_bb_insns (basic_block);
static rtx first_active_insn (basic_block);
@@ -123,6 +120,7 @@ mark_loop_exit_edges (void)
edge e;
flow_loops_find (&loops, LOOP_TREE);
+ free_dominance_info (CDI_DOMINATORS);
if (loops.num > 1)
{
@@ -2105,8 +2103,8 @@ merge_if_block (struct ce_if_block * ce_info)
{
bb = fallthru;
fallthru = block_fallthru (bb);
- if (post_dominators)
- delete_from_dominance_info (post_dominators, bb);
+ if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY)
+ delete_from_dominance_info (CDI_POST_DOMINATORS, bb);
merge_blocks (combo_bb, bb);
num_true_changes++;
}
@@ -2122,8 +2120,8 @@ merge_if_block (struct ce_if_block * ce_info)
if (combo_bb->global_live_at_end)
COPY_REG_SET (combo_bb->global_live_at_end,
then_bb->global_live_at_end);
- if (post_dominators)
- delete_from_dominance_info (post_dominators, then_bb);
+ if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY)
+ delete_from_dominance_info (CDI_POST_DOMINATORS, then_bb);
merge_blocks (combo_bb, then_bb);
num_true_changes++;
}
@@ -2133,8 +2131,8 @@ merge_if_block (struct ce_if_block * ce_info)
get their addresses taken. */
if (else_bb)
{
- if (post_dominators)
- delete_from_dominance_info (post_dominators, else_bb);
+ if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY)
+ delete_from_dominance_info (CDI_POST_DOMINATORS, else_bb);
merge_blocks (combo_bb, else_bb);
num_true_changes++;
}
@@ -2190,8 +2188,8 @@ merge_if_block (struct ce_if_block * ce_info)
COPY_REG_SET (combo_bb->global_live_at_end,
join_bb->global_live_at_end);
- if (post_dominators)
- delete_from_dominance_info (post_dominators, join_bb);
+ if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY)
+ delete_from_dominance_info (CDI_POST_DOMINATORS, join_bb);
merge_blocks (combo_bb, join_bb);
num_true_changes++;
}
@@ -2271,7 +2269,7 @@ find_if_header (basic_block test_bb, int pass)
&& find_cond_trap (test_bb, then_edge, else_edge))
goto success;
- if (post_dominators
+ if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY
&& (! HAVE_conditional_execution || reload_completed))
{
if (find_if_case_1 (test_bb, then_edge, else_edge))
@@ -2646,8 +2644,8 @@ find_cond_trap (basic_block test_bb, edge then_edge, edge else_edge)
remove_edge (trap_bb == then_bb ? then_edge : else_edge);
if (trap_bb->pred == NULL)
{
- if (post_dominators)
- delete_from_dominance_info (post_dominators, trap_bb);
+ if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY)
+ delete_from_dominance_info (CDI_POST_DOMINATORS, trap_bb);
delete_block (trap_bb);
}
@@ -2831,8 +2829,8 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge)
new_bb = redirect_edge_and_branch_force (FALLTHRU_EDGE (test_bb), else_bb);
then_bb_index = then_bb->index;
- if (post_dominators)
- delete_from_dominance_info (post_dominators, then_bb);
+ if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY)
+ delete_from_dominance_info (CDI_POST_DOMINATORS, then_bb);
delete_block (then_bb);
/* Make rest of code believe that the newly created block is the THEN_BB
@@ -2841,8 +2839,8 @@ find_if_case_1 (basic_block test_bb, edge then_edge, edge else_edge)
{
new_bb->index = then_bb_index;
BASIC_BLOCK (then_bb_index) = new_bb;
- if (post_dominators)
- add_to_dominance_info (post_dominators, new_bb);
+ if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY)
+ add_to_dominance_info (CDI_POST_DOMINATORS, new_bb);
}
/* We've possibly created jump to next insn, cleanup_cfg will solve that
later. */
@@ -2884,7 +2882,7 @@ find_if_case_2 (basic_block test_bb, edge then_edge, edge else_edge)
if (note && INTVAL (XEXP (note, 0)) >= REG_BR_PROB_BASE / 2)
;
else if (else_succ->dest->index < 0
- || dominated_by_p (post_dominators, then_bb,
+ || dominated_by_p (CDI_POST_DOMINATORS, then_bb,
else_succ->dest))
;
else
@@ -2911,8 +2909,8 @@ find_if_case_2 (basic_block test_bb, edge then_edge, edge else_edge)
then_bb->global_live_at_start,
else_bb->global_live_at_end, BITMAP_IOR);
- if (post_dominators)
- delete_from_dominance_info (post_dominators, else_bb);
+ if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY)
+ delete_from_dominance_info (CDI_POST_DOMINATORS, else_bb);
delete_block (else_bb);
num_true_changes++;
@@ -3217,11 +3215,9 @@ if_convert (int x_life_data_ok)
free_basic_block_vars (1);
/* Compute postdominators if we think we'll use them. */
- post_dominators = NULL;
if (HAVE_conditional_execution || life_data_ok)
- {
- post_dominators = calculate_dominance_info (CDI_POST_DOMINATORS);
- }
+ calculate_dominance_info (CDI_POST_DOMINATORS);
+
if (life_data_ok)
clear_bb_flags ();
@@ -3258,8 +3254,7 @@ if_convert (int x_life_data_ok)
fprintf (rtl_dump_file, "\n\n========== no more changes\n");
#endif
- if (post_dominators)
- free_dominance_info (post_dominators);
+ free_dominance_info (CDI_POST_DOMINATORS);
if (rtl_dump_file)
fflush (rtl_dump_file);
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 68086ee9245..2fa7728ebde 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,11 @@
+2003-12-25 Andrew Pinski <pinskia@physics.uc.edu>
+
+ * parse.y (catch_clause_parameter): Fix typo.
+
+ PR java/13404
+ * parse.y: (catch_clause_parameter): Return early if $3, aka
+ formal_parameter, is null.
+
2003-12-20 Kazu Hirata <kazu@cs.umass.edu>
* class.c: Remove uses of "register" specifier in
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 02b445b8b60..c8b4596a587 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -1905,15 +1905,24 @@ catch_clause_parameter:
formal_parameter (CCBP). The formal parameter is
declared initialized by the appropriate function
call */
- tree ccpb = enter_block ();
- tree init = build_assignment
- (ASSIGN_TK, $2.location, TREE_PURPOSE ($3),
- build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
- declare_local_variables (0, TREE_VALUE ($3),
- build_tree_list (TREE_PURPOSE ($3),
- init));
- $$ = build1 (CATCH_EXPR, NULL_TREE, ccpb);
- EXPR_WFL_LINECOL ($$) = $1.location;
+ tree ccpb;
+ tree init;
+ if ($3)
+ {
+ ccpb = enter_block ();
+ init = build_assignment
+ (ASSIGN_TK, $2.location, TREE_PURPOSE ($3),
+ build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
+ declare_local_variables (0, TREE_VALUE ($3),
+ build_tree_list
+ (TREE_PURPOSE ($3), init));
+ $$ = build1 (CATCH_EXPR, NULL_TREE, ccpb);
+ EXPR_WFL_LINECOL ($$) = $1.location;
+ }
+ else
+ {
+ $$ = error_mark_node;
+ }
}
| CATCH_TK error
{yyerror ("'(' expected"); RECOVER; $$ = NULL_TREE;}
diff --git a/gcc/longlong.h b/gcc/longlong.h
index 2fb68e7c373..8a7d3dfc083 100644
--- a/gcc/longlong.h
+++ b/gcc/longlong.h
@@ -186,7 +186,7 @@ do { \
UDItype __umulsidi3 (USItype, USItype);
#endif
-#if defined (__arm__) && W_TYPE_SIZE == 32
+#if defined (__arm__) && !defined (__thumb__) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("adds %1, %4, %5\n\tadc %0, %2, %3" \
: "=r" ((USItype) (sh)), \
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index 13285a31e61..0b882d9e163 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -53,7 +53,9 @@ loop_optimizer_init (FILE *dumpfile)
/* No loops. */
flow_loops_free (loops);
+ free_dominance_info (CDI_DOMINATORS);
free (loops);
+
/* Make chain. */
FOR_EACH_BB (bb)
if (bb->next_bb != EXIT_BLOCK_PTR)
@@ -81,7 +83,7 @@ loop_optimizer_init (FILE *dumpfile)
flow_loops_dump (loops, dumpfile, NULL, 1);
#ifdef ENABLE_CHECKING
- verify_dominators (loops->cfg.dom);
+ verify_dominators (CDI_DOMINATORS);
verify_loop_structure (loops);
#endif
@@ -105,6 +107,7 @@ loop_optimizer_finalize (struct loops *loops, FILE *dumpfile)
/* Clean up. */
flow_loops_free (loops);
+ free_dominance_info (CDI_DOMINATORS);
free (loops);
/* Finalize changes. */
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index dde3c7439af..6c796af577c 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -68,14 +68,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
static void decide_unrolling_and_peeling (struct loops *, int);
static void peel_loops_completely (struct loops *, int);
-static void decide_peel_simple (struct loops *, struct loop *, int);
-static void decide_peel_once_rolling (struct loops *, struct loop *, int);
-static void decide_peel_completely (struct loops *, struct loop *, int);
-static void decide_unroll_stupid (struct loops *, struct loop *, int);
-static void decide_unroll_constant_iterations (struct loops *,
- struct loop *, int);
-static void decide_unroll_runtime_iterations (struct loops *, struct loop *,
- int);
+static void decide_peel_simple (struct loop *, int);
+static void decide_peel_once_rolling (struct loop *, int);
+static void decide_peel_completely (struct loop *, int);
+static void decide_unroll_stupid (struct loop *, int);
+static void decide_unroll_constant_iterations (struct loop *, int);
+static void decide_unroll_runtime_iterations (struct loop *, int);
static void peel_loop_simple (struct loops *, struct loop *);
static void peel_loop_completely (struct loops *, struct loop *);
static void unroll_loop_stupid (struct loops *, struct loop *);
@@ -140,7 +138,7 @@ unroll_and_peel_loops (struct loops *loops, int flags)
if (check)
{
#ifdef ENABLE_CHECKING
- verify_dominators (loops->cfg.dom);
+ verify_dominators (CDI_DOMINATORS);
verify_loop_structure (loops);
#endif
}
@@ -178,15 +176,15 @@ peel_loops_completely (struct loops *loops, int flags)
loop->ninsns = num_loop_insns (loop);
- decide_peel_once_rolling (loops, loop, flags);
+ decide_peel_once_rolling (loop, flags);
if (loop->lpt_decision.decision == LPT_NONE)
- decide_peel_completely (loops, loop, flags);
+ decide_peel_completely (loop, flags);
if (loop->lpt_decision.decision == LPT_PEEL_COMPLETELY)
{
peel_loop_completely (loops, loop);
#ifdef ENABLE_CHECKING
- verify_dominators (loops->cfg.dom);
+ verify_dominators (CDI_DOMINATORS);
verify_loop_structure (loops);
#endif
}
@@ -254,13 +252,13 @@ decide_unrolling_and_peeling (struct loops *loops, int flags)
/* Try transformations one by one in decreasing order of
priority. */
- decide_unroll_constant_iterations (loops, loop, flags);
+ decide_unroll_constant_iterations (loop, flags);
if (loop->lpt_decision.decision == LPT_NONE)
- decide_unroll_runtime_iterations (loops, loop, flags);
+ decide_unroll_runtime_iterations (loop, flags);
if (loop->lpt_decision.decision == LPT_NONE)
- decide_unroll_stupid (loops, loop, flags);
+ decide_unroll_stupid (loop, flags);
if (loop->lpt_decision.decision == LPT_NONE)
- decide_peel_simple (loops, loop, flags);
+ decide_peel_simple (loop, flags);
loop = next;
}
@@ -269,8 +267,7 @@ decide_unrolling_and_peeling (struct loops *loops, int flags)
/* Decide whether the LOOP is once rolling and suitable for complete
peeling. */
static void
-decide_peel_once_rolling (struct loops *loops, struct loop *loop,
- int flags ATTRIBUTE_UNUSED)
+decide_peel_once_rolling (struct loop *loop, int flags ATTRIBUTE_UNUSED)
{
if (rtl_dump_file)
fprintf (rtl_dump_file, ";; Considering peeling once rolling loop\n");
@@ -284,7 +281,7 @@ decide_peel_once_rolling (struct loops *loops, struct loop *loop,
}
/* Check for simple loops. */
- loop->simple = simple_loop_p (loops, loop, &loop->desc);
+ loop->simple = simple_loop_p (loop, &loop->desc);
loop->has_desc = 1;
/* Check number of iterations. */
@@ -303,8 +300,7 @@ decide_peel_once_rolling (struct loops *loops, struct loop *loop,
/* Decide whether the LOOP is suitable for complete peeling. */
static void
-decide_peel_completely (struct loops *loops, struct loop *loop,
- int flags ATTRIBUTE_UNUSED)
+decide_peel_completely (struct loop *loop, int flags ATTRIBUTE_UNUSED)
{
unsigned npeel;
@@ -352,7 +348,7 @@ decide_peel_completely (struct loops *loops, struct loop *loop,
/* Check for simple loops. */
if (!loop->has_desc)
{
- loop->simple = simple_loop_p (loops, loop, &loop->desc);
+ loop->simple = simple_loop_p (loop, &loop->desc);
loop->has_desc = 1;
}
@@ -441,8 +437,7 @@ peel_loop_completely (struct loops *loops, struct loop *loop)
/* Decide whether to unroll LOOP iterating constant number of times and how much. */
static void
-decide_unroll_constant_iterations (struct loops *loops, struct loop *loop,
- int flags)
+decide_unroll_constant_iterations (struct loop *loop, int flags)
{
unsigned nunroll, nunroll_by_av, best_copies, best_unroll = -1, n_copies, i;
@@ -475,7 +470,7 @@ decide_unroll_constant_iterations (struct loops *loops, struct loop *loop,
/* Check for simple loops. */
if (!loop->has_desc)
{
- loop->simple = simple_loop_p (loops, loop, &loop->desc);
+ loop->simple = simple_loop_p (loop, &loop->desc);
loop->has_desc = 1;
}
@@ -649,8 +644,7 @@ unroll_loop_constant_iterations (struct loops *loops, struct loop *loop)
/* Decide whether to unroll LOOP iterating runtime computable number of times
and how much. */
static void
-decide_unroll_runtime_iterations (struct loops *loops, struct loop *loop,
- int flags)
+decide_unroll_runtime_iterations (struct loop *loop, int flags)
{
unsigned nunroll, nunroll_by_av, i;
@@ -683,7 +677,7 @@ decide_unroll_runtime_iterations (struct loops *loops, struct loop *loop,
/* Check for simple loops. */
if (!loop->has_desc)
{
- loop->simple = simple_loop_p (loops, loop, &loop->desc);
+ loop->simple = simple_loop_p (loop, &loop->desc);
loop->has_desc = 1;
}
@@ -774,7 +768,7 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
unsigned nldom;
basic_block *ldom;
- nldom = get_dominated_by (loops->cfg.dom, body[i], &ldom);
+ nldom = get_dominated_by (CDI_DOMINATORS, body[i], &ldom);
for (j = 0; j < nldom; j++)
if (!flow_bb_inside_loop_p (loop, ldom[j]))
dom_bbs[n_dom_bbs++] = ldom[j];
@@ -821,7 +815,7 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
end_sequence ();
/* Precondition the loop. */
- loop_split_edge_with (loop_preheader_edge (loop), init_code, loops);
+ loop_split_edge_with (loop_preheader_edge (loop), init_code);
remove_edges = xcalloc (max_unroll + n_peel + 1, sizeof (edge));
n_remove_edges = 0;
@@ -844,7 +838,7 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
/* Record the place where switch will be built for preconditioning. */
swtch = loop_split_edge_with (loop_preheader_edge (loop),
- NULL_RTX, loops);
+ NULL_RTX);
for (i = 0; i < n_peel; i++)
{
@@ -862,8 +856,7 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
j = n_peel - i - (extra_zero_check ? 0 : 1);
p = REG_BR_PROB_BASE / (i + 2);
- preheader = loop_split_edge_with (loop_preheader_edge (loop),
- NULL_RTX, loops);
+ preheader = loop_split_edge_with (loop_preheader_edge (loop), NULL_RTX);
label = block_label (preheader);
start_sequence ();
do_compare_rtx_and_jump (copy_rtx (niter), GEN_INT (j), EQ, 0,
@@ -879,8 +872,8 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
branch_code = get_insns ();
end_sequence ();
- swtch = loop_split_edge_with (swtch->pred, branch_code, loops);
- set_immediate_dominator (loops->cfg.dom, preheader, swtch);
+ swtch = loop_split_edge_with (swtch->pred, branch_code);
+ set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
swtch->succ->probability = REG_BR_PROB_BASE - p;
e = make_edge (swtch, preheader,
swtch->succ->flags & EDGE_IRREDUCIBLE_LOOP);
@@ -892,8 +885,7 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
/* Add branch for zero iterations. */
p = REG_BR_PROB_BASE / (max_unroll + 1);
swtch = ezc_swtch;
- preheader = loop_split_edge_with (loop_preheader_edge (loop),
- NULL_RTX, loops);
+ preheader = loop_split_edge_with (loop_preheader_edge (loop), NULL_RTX);
label = block_label (preheader);
start_sequence ();
do_compare_rtx_and_jump (copy_rtx (niter), const0_rtx, EQ, 0,
@@ -909,8 +901,8 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
branch_code = get_insns ();
end_sequence ();
- swtch = loop_split_edge_with (swtch->succ, branch_code, loops);
- set_immediate_dominator (loops->cfg.dom, preheader, swtch);
+ swtch = loop_split_edge_with (swtch->succ, branch_code);
+ set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
swtch->succ->probability = REG_BR_PROB_BASE - p;
e = make_edge (swtch, preheader,
swtch->succ->flags & EDGE_IRREDUCIBLE_LOOP);
@@ -918,7 +910,7 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
}
/* Recount dominators for outer blocks. */
- iterate_fix_dominators (loops->cfg.dom, dom_bbs, n_dom_bbs);
+ iterate_fix_dominators (CDI_DOMINATORS, dom_bbs, n_dom_bbs);
/* And unroll loop. */
@@ -946,7 +938,7 @@ unroll_loop_runtime_iterations (struct loops *loops, struct loop *loop)
/* Decide whether to simply peel LOOP and how much. */
static void
-decide_peel_simple (struct loops *loops, struct loop *loop, int flags)
+decide_peel_simple (struct loop *loop, int flags)
{
unsigned npeel;
@@ -975,7 +967,7 @@ decide_peel_simple (struct loops *loops, struct loop *loop, int flags)
/* Check for simple loops. */
if (!loop->has_desc)
{
- loop->simple = simple_loop_p (loops, loop, &loop->desc);
+ loop->simple = simple_loop_p (loop, &loop->desc);
loop->has_desc = 1;
}
@@ -1062,7 +1054,7 @@ peel_loop_simple (struct loops *loops, struct loop *loop)
/* Decide whether to unroll LOOP stupidly and how much. */
static void
-decide_unroll_stupid (struct loops *loops, struct loop *loop, int flags)
+decide_unroll_stupid (struct loop *loop, int flags)
{
unsigned nunroll, nunroll_by_av, i;
@@ -1095,7 +1087,7 @@ decide_unroll_stupid (struct loops *loops, struct loop *loop, int flags)
/* Check for simple loops. */
if (!loop->has_desc)
{
- loop->simple = simple_loop_p (loops, loop, &loop->desc);
+ loop->simple = simple_loop_p (loop, &loop->desc);
loop->has_desc = 1;
}
diff --git a/gcc/loop-unswitch.c b/gcc/loop-unswitch.c
index f276b7307a4..4cfaa2f6255 100644
--- a/gcc/loop-unswitch.c
+++ b/gcc/loop-unswitch.c
@@ -81,7 +81,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
static struct loop *unswitch_loop (struct loops *, struct loop *,
basic_block);
static void unswitch_single_loop (struct loops *, struct loop *, rtx, int);
-static bool may_unswitch_on_p (struct loops *, basic_block, struct loop *,
+static bool may_unswitch_on_p (basic_block, struct loop *,
basic_block *);
static rtx reversed_condition (rtx);
@@ -107,7 +107,7 @@ unswitch_loops (struct loops *loops)
unswitch_single_loop (loops, loop, NULL_RTX, 0);
#ifdef ENABLE_CHECKING
- verify_dominators (loops->cfg.dom);
+ verify_dominators (CDI_DOMINATORS);
verify_loop_structure (loops);
#endif
}
@@ -117,8 +117,7 @@ unswitch_loops (struct loops *loops)
basic blocks (for what it means see comments below). List of basic blocks
inside LOOP is provided in BODY to save time. */
static bool
-may_unswitch_on_p (struct loops *loops, basic_block bb, struct loop *loop,
- basic_block *body)
+may_unswitch_on_p (basic_block bb, struct loop *loop, basic_block *body)
{
rtx test;
unsigned i;
@@ -136,7 +135,7 @@ may_unswitch_on_p (struct loops *loops, basic_block bb, struct loop *loop,
/* It must be executed just once each iteration (because otherwise we
are unable to update dominator/irreducible loop information correctly). */
- if (!just_once_each_iteration_p (loops, loop, bb))
+ if (!just_once_each_iteration_p (loop, bb))
return false;
/* Condition must be invariant. We use just a stupid test of invariantness
@@ -239,7 +238,7 @@ unswitch_single_loop (struct loops *loops, struct loop *loop,
/* Find a bb to unswitch on. */
bbs = get_loop_body (loop);
for (i = 0; i < loop->num_nodes; i++)
- if (may_unswitch_on_p (loops, bbs[i], loop, bbs))
+ if (may_unswitch_on_p (bbs[i], loop, bbs))
break;
if (i == loop->num_nodes)
@@ -295,7 +294,7 @@ unswitch_single_loop (struct loops *loops, struct loop *loop,
rconds = cond_checked;
/* Separate condition in a single basic block. */
- bb = split_loop_bb (loops, bbs[i], PREV_INSN (split_before))->dest;
+ bb = split_loop_bb (bbs[i], PREV_INSN (split_before))->dest;
free (bbs);
true_first = !(bb->succ->flags & EDGE_FALLTHRU);
if (rtl_dump_file)
@@ -335,7 +334,7 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on)
if (!unswitch_on->succ || !unswitch_on->succ->succ_next ||
unswitch_on->succ->succ_next->succ_next)
abort ();
- if (!just_once_each_iteration_p (loops, loop, unswitch_on))
+ if (!just_once_each_iteration_p (loop, unswitch_on))
abort ();
if (loop->inner)
abort ();
@@ -382,7 +381,7 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on)
switch_bb->succ->flags &= ~EDGE_IRREDUCIBLE_LOOP;
switch_bb->succ->succ_next->flags &= ~EDGE_IRREDUCIBLE_LOOP;
}
- add_to_dominance_info (loops->cfg.dom, switch_bb);
+ add_to_dominance_info (CDI_DOMINATORS, switch_bb);
unswitch_on->rbi->copy = unswitch_on_alt;
/* Loopify from the copy of LOOP body, constructing the new loop. */
@@ -402,5 +401,9 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on)
fix_loop_placement (loop);
fix_loop_placement (nloop);
+ /* Preserve the simple loop preheaders. */
+ loop_split_edge_with (loop_preheader_edge (loop), NULL_RTX);
+ loop_split_edge_with (loop_preheader_edge (nloop), NULL_RTX);
+
return nloop;
}
diff --git a/gcc/opts.c b/gcc/opts.c
index 0497cb01709..e0583691e13 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -148,6 +148,13 @@ static unsigned int columns = 80;
/* What to print when a switch has no documentation. */
static const char undocumented_msg[] = N_("This switch lacks documentation");
+/* Used for bookkeeping on whether user set these flags so
+ -fprofile-use/-fprofile-generate does not use them. */
+static bool profile_arc_flag_set, flag_profile_values_set;
+static bool flag_unroll_loops_set, flag_tracer_set;
+static bool flag_value_profile_transformations_set;
+static bool flag_peel_loops_set, flag_branch_probabilities_set;
+
/* Input file names. */
const char **in_fnames;
unsigned num_in_fnames;
@@ -882,6 +889,7 @@ common_handle_option (size_t scode, const char *arg,
break;
case OPT_fbranch_probabilities:
+ flag_branch_probabilities_set = true;
flag_branch_probabilities = value;
break;
@@ -1135,6 +1143,7 @@ common_handle_option (size_t scode, const char *arg,
break;
case OPT_fpeel_loops:
+ flag_peel_loops_set = true;
flag_peel_loops = value;
break;
@@ -1167,14 +1176,41 @@ common_handle_option (size_t scode, const char *arg,
break;
case OPT_fprofile_arcs:
+ profile_arc_flag_set = true;
profile_arc_flag = value;
break;
+ case OPT_fprofile_use:
+ if (!flag_branch_probabilities_set)
+ flag_branch_probabilities = value;
+ if (!flag_profile_values_set)
+ flag_profile_values = value;
+ if (!flag_unroll_loops_set)
+ flag_unroll_loops = value;
+ if (!flag_peel_loops_set)
+ flag_peel_loops = value;
+ if (!flag_tracer_set)
+ flag_tracer = value;
+ if (!flag_value_profile_transformations_set)
+ flag_value_profile_transformations = value;
+ break;
+
+ case OPT_fprofile_generate:
+ if (!profile_arc_flag_set)
+ profile_arc_flag = value;
+ if (!flag_profile_values_set)
+ flag_profile_values = value;
+ if (!flag_value_profile_transformations_set)
+ flag_value_profile_transformations = value;
+ break;
+
case OPT_fprofile_values:
+ flag_profile_values_set = true;
flag_profile_values = value;
break;
case OPT_fvpt:
+ flag_value_profile_transformations_set = value;
flag_value_profile_transformations = value;
break;
@@ -1358,6 +1394,7 @@ common_handle_option (size_t scode, const char *arg,
break;
case OPT_ftracer:
+ flag_tracer_set = true;
flag_tracer = value;
break;
@@ -1378,6 +1415,7 @@ common_handle_option (size_t scode, const char *arg,
break;
case OPT_funroll_loops:
+ flag_unroll_loops_set = true;
flag_unroll_loops = value;
break;
@@ -1421,19 +1459,6 @@ common_handle_option (size_t scode, const char *arg,
set_debug_level (SDB_DEBUG, false, arg);
break;
- case OPT_gdwarf:
- if (*arg)
- {
- error ("use -gdwarf -gN for DWARF v1 level N, "
- "and -gdwarf-2 for DWARF v2" );
- break;
- }
-
- /* Fall through. */
- case OPT_gdwarf_:
- set_debug_level (DWARF_DEBUG, code == OPT_gdwarf_, arg);
- break;
-
case OPT_gdwarf_2:
set_debug_level (DWARF2_DEBUG, false, arg);
break;
diff --git a/gcc/predict.c b/gcc/predict.c
index 30de8666e23..74a1f24c3ad 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -72,10 +72,8 @@ static void estimate_loops_at_level (struct loop *loop);
static void propagate_freq (struct loop *);
static void estimate_bb_frequencies (struct loops *);
static void counts_to_freqs (void);
-static void process_note_predictions (basic_block, int *, dominance_info,
- dominance_info);
-static void process_note_prediction (basic_block, int *, dominance_info,
- dominance_info, int, int);
+static void process_note_predictions (basic_block, int *);
+static void process_note_prediction (basic_block, int *, int, int);
static bool last_basic_block_p (basic_block);
static void compute_function_frequency (void);
static void choose_function_section (void);
@@ -393,13 +391,12 @@ combine_predictions_for_insn (rtx insn, basic_block bb)
void
estimate_probability (struct loops *loops_info)
{
- dominance_info dominators, post_dominators;
basic_block bb;
unsigned i;
connect_infinite_loops_to_exit ();
- dominators = calculate_dominance_info (CDI_DOMINATORS);
- post_dominators = calculate_dominance_info (CDI_POST_DOMINATORS);
+ calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_POST_DOMINATORS);
/* Try to predict out blocks in a loop that are not part of a
natural loop. */
@@ -412,11 +409,10 @@ estimate_probability (struct loops *loops_info)
struct loop_desc desc;
unsigned HOST_WIDE_INT niter;
- flow_loop_scan (loops_info, loop, LOOP_EXIT_EDGES);
+ flow_loop_scan (loop, LOOP_EXIT_EDGES);
exits = loop->num_exits;
- if (simple_loop_p (loops_info, loop, &desc)
- && desc.const_iter)
+ if (simple_loop_p (loop, &desc) && desc.const_iter)
{
int prob;
niter = desc.niter + 1;
@@ -500,8 +496,8 @@ estimate_probability (struct loops *loops_info)
/* Look for block we are guarding (ie we dominate it,
but it doesn't postdominate us). */
if (e->dest != EXIT_BLOCK_PTR && e->dest != bb
- && dominated_by_p (dominators, e->dest, e->src)
- && !dominated_by_p (post_dominators, e->src, e->dest))
+ && dominated_by_p (CDI_DOMINATORS, e->dest, e->src)
+ && !dominated_by_p (CDI_POST_DOMINATORS, e->src, e->dest))
{
rtx insn;
@@ -618,8 +614,7 @@ estimate_probability (struct loops *loops_info)
&& bb->succ->succ_next != NULL)
combine_predictions_for_insn (BB_END (bb), bb);
- free_dominance_info (post_dominators);
- free_dominance_info (dominators);
+ free_dominance_info (CDI_POST_DOMINATORS);
remove_fake_edges ();
estimate_bb_frequencies (loops_info);
@@ -719,10 +714,7 @@ last_basic_block_p (basic_block bb)
on demand, so -1 may be there in case this was not needed yet). */
static void
-process_note_prediction (basic_block bb, int *heads,
- dominance_info dominators,
- dominance_info post_dominators, int pred,
- int flags)
+process_note_prediction (basic_block bb, int *heads, int pred, int flags)
{
edge e;
int y;
@@ -736,18 +728,18 @@ process_note_prediction (basic_block bb, int *heads,
find first dominator that we do not post-dominate (we are
using already known members of heads array). */
basic_block ai = bb;
- basic_block next_ai = get_immediate_dominator (dominators, bb);
+ basic_block next_ai = get_immediate_dominator (CDI_DOMINATORS, bb);
int head;
while (heads[next_ai->index] < 0)
{
- if (!dominated_by_p (post_dominators, next_ai, bb))
+ if (!dominated_by_p (CDI_POST_DOMINATORS, next_ai, bb))
break;
heads[next_ai->index] = ai->index;
ai = next_ai;
- next_ai = get_immediate_dominator (dominators, next_ai);
+ next_ai = get_immediate_dominator (CDI_DOMINATORS, next_ai);
}
- if (!dominated_by_p (post_dominators, next_ai, bb))
+ if (!dominated_by_p (CDI_POST_DOMINATORS, next_ai, bb))
head = next_ai->index;
else
head = heads[next_ai->index];
@@ -769,7 +761,7 @@ process_note_prediction (basic_block bb, int *heads,
return;
for (e = BASIC_BLOCK (y)->succ; e; e = e->succ_next)
if (e->dest->index >= 0
- && dominated_by_p (post_dominators, e->dest, bb))
+ && dominated_by_p (CDI_POST_DOMINATORS, e->dest, bb))
predict_edge_def (e, pred, taken);
}
@@ -778,9 +770,7 @@ process_note_prediction (basic_block bb, int *heads,
process_note_prediction. */
static void
-process_note_predictions (basic_block bb, int *heads,
- dominance_info dominators,
- dominance_info post_dominators)
+process_note_predictions (basic_block bb, int *heads)
{
rtx insn;
edge e;
@@ -813,8 +803,6 @@ process_note_predictions (basic_block bb, int *heads,
/* Process single prediction note. */
process_note_prediction (bb,
heads,
- dominators,
- post_dominators,
alg, (int) NOTE_PREDICTION_FLAGS (insn));
delete_insn (insn);
}
@@ -827,10 +815,7 @@ process_note_predictions (basic_block bb, int *heads,
/* This block ended from other reasons than because of return.
If it is because of noreturn call, this should certainly not
be taken. Otherwise it is probably some error recovery. */
- process_note_prediction (bb,
- heads,
- dominators,
- post_dominators, PRED_NORETURN, NOT_TAKEN);
+ process_note_prediction (bb, heads, PRED_NORETURN, NOT_TAKEN);
}
}
@@ -841,15 +826,14 @@ void
note_prediction_to_br_prob (void)
{
basic_block bb;
- dominance_info post_dominators, dominators;
int *heads;
/* To enable handling of noreturn blocks. */
add_noreturn_fake_exit_edges ();
connect_infinite_loops_to_exit ();
- post_dominators = calculate_dominance_info (CDI_POST_DOMINATORS);
- dominators = calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_POST_DOMINATORS);
+ calculate_dominance_info (CDI_DOMINATORS);
heads = xmalloc (sizeof (int) * last_basic_block);
memset (heads, -1, sizeof (int) * last_basic_block);
@@ -858,10 +842,10 @@ note_prediction_to_br_prob (void)
/* Process all prediction notes. */
FOR_EACH_BB (bb)
- process_note_predictions (bb, heads, dominators, post_dominators);
+ process_note_predictions (bb, heads);
- free_dominance_info (post_dominators);
- free_dominance_info (dominators);
+ free_dominance_info (CDI_POST_DOMINATORS);
+ free_dominance_info (CDI_DOMINATORS);
free (heads);
remove_fake_edges ();
diff --git a/gcc/sbitmap.c b/gcc/sbitmap.c
index 3cec45de627..1d27a871097 100644
--- a/gcc/sbitmap.c
+++ b/gcc/sbitmap.c
@@ -250,9 +250,16 @@ sbitmap_not (sbitmap dst, sbitmap src)
unsigned int i, n = dst->size;
sbitmap_ptr dstp = dst->elms;
sbitmap_ptr srcp = src->elms;
+ unsigned int last_bit;
for (i = 0; i < n; i++)
*dstp++ = ~*srcp++;
+
+ /* Zero all bits past n_bits, by ANDing dst with sbitmap_ones. */
+ last_bit = src->n_bits % SBITMAP_ELT_BITS;
+ if (last_bit)
+ dst->elms[n-1] = dst->elms[n-1]
+ & ((SBITMAP_ELT_TYPE)-1 >> (SBITMAP_ELT_BITS - last_bit));
}
/* Set the bits in DST to be the difference between the bits
@@ -298,7 +305,7 @@ sbitmap_a_and_b_cg (sbitmap dst, sbitmap a, sbitmap b)
for (i = 0; i < n; i++)
{
SBITMAP_ELT_TYPE tmp = *ap++ & *bp++;
- changed = *dstp ^ tmp;
+ changed |= *dstp ^ tmp;
*dstp++ = tmp;
}
@@ -332,7 +339,7 @@ sbitmap_a_xor_b_cg (sbitmap dst, sbitmap a, sbitmap b)
for (i = 0; i < n; i++)
{
SBITMAP_ELT_TYPE tmp = *ap++ ^ *bp++;
- changed = *dstp ^ tmp;
+ changed |= *dstp ^ tmp;
*dstp++ = tmp;
}
@@ -366,7 +373,7 @@ sbitmap_a_or_b_cg (sbitmap dst, sbitmap a, sbitmap b)
for (i = 0; i < n; i++)
{
SBITMAP_ELT_TYPE tmp = *ap++ | *bp++;
- changed = *dstp ^ tmp;
+ changed |= *dstp ^ tmp;
*dstp++ = tmp;
}
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index 138bab36b96..b8e474d0b44 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -155,7 +155,7 @@ static int *containing_rgn;
void debug_regions (void);
static void find_single_block_region (void);
-static void find_rgns (struct edge_list *, dominance_info);
+static void find_rgns (struct edge_list *);
static int too_large (int, int *, int *);
extern void debug_live (int, int);
@@ -613,7 +613,7 @@ too_large (int block, int *num_bbs, int *num_insns)
of edge tables. That would simplify it somewhat. */
static void
-find_rgns (struct edge_list *edge_list, dominance_info dom)
+find_rgns (struct edge_list *edge_list)
{
int *max_hdr, *dfs_nr, *stack, *degree;
char no_loops = 1;
@@ -827,7 +827,7 @@ find_rgns (struct edge_list *edge_list, dominance_info dom)
{
/* Now verify that the block is dominated by the loop
header. */
- if (!dominated_by_p (dom, jbb, bb))
+ if (!dominated_by_p (CDI_DOMINATORS, jbb, bb))
break;
}
}
@@ -2597,7 +2597,6 @@ init_regions (void)
}
else
{
- dominance_info dom;
struct edge_list *edge_list;
/* The scheduler runs after estimate_probabilities; therefore, we
@@ -2607,7 +2606,7 @@ init_regions (void)
edge_list = create_edge_list ();
/* Compute the dominators and post dominators. */
- dom = calculate_dominance_info (CDI_DOMINATORS);
+ calculate_dominance_info (CDI_DOMINATORS);
/* build_control_flow will return nonzero if it detects unreachable
blocks or any other irregularity with the cfg which prevents
@@ -2615,7 +2614,7 @@ init_regions (void)
if (build_control_flow (edge_list) != 0)
find_single_block_region ();
else
- find_rgns (edge_list, dom);
+ find_rgns (edge_list);
if (sched_verbose >= 3)
debug_regions ();
@@ -2625,7 +2624,7 @@ init_regions (void)
/* For now. This will move as more and more of haifa is converted
to using the cfg code in flow.c. */
- free_dominance_info (dom);
+ free_dominance_info (CDI_DOMINATORS);
}
}
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index e8c7ba4dc9a..1272a0cbbcc 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -435,7 +435,9 @@ layout_decl (tree decl, unsigned int known_align)
enum machine_mode xmode
= mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1);
- if (xmode != BLKmode && known_align >= GET_MODE_ALIGNMENT (xmode))
+ if (xmode != BLKmode
+ && (known_align == 0
+ || known_align >= GET_MODE_ALIGNMENT (xmode)))
{
DECL_ALIGN (decl) = MAX (GET_MODE_ALIGNMENT (xmode),
DECL_ALIGN (decl));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 965e1547cf1..8660ccf4cde 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -33,6 +33,132 @@
* g++.dg/lookup/java2.C: Likewise.
* gcc.dg/cpp/lexident.c: Likewise.
+2003-12-30 Mark Mitchell <mark@codesourcery.com>
+
+ * g++.dg/abi/vbase10.C: XFAIL on arm*-*-*.
+
+2003-12-30 Kazu Hirata <kazu@cs.umass.edu>
+
+ * g++.old-deja/g++.jason/thunk2.C: Remove traces of dead
+ ports.
+ * g++.old-deja/g++.jason/thunk3.C: Likewise.
+ * g++.old-deja/g++.law/profile1.C: Likewise.
+ * gcc.c-torture/compile/981006-1.c: Likewise.
+ * gcc.c-torture/execute/loop-2e.x: Likewise.
+ * gcc.c-torture/execute/loop-2f.x: Remove.
+ * gcc.c-torture/execute/loop-2g.x: Likewise.
+ * gcc.c-torture/execute/strct-varg-1.x: Likewise.
+ * gcc.dg/20020312-2.c: Remove traces of dead ports.
+
+2003-12-30 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/13507
+ * g++.dg/ext/attrib11.C: New test.
+
+ PR c++/13494
+ * g++.dg/template/array2-1.C: New test.
+ * g++.dg/template/array2-2.C: New test.
+
+2003-12-29 Mark Mitchell <mark@codesourcery.com>
+
+ * g++.old-deja/g++.pt/static11.C: Correct XFAIL syntax.
+
+2003-12-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/12774
+ * g++.dg/template/array1-1.C: New test.
+ * g++.dg/template/array1-2.C: New test.
+
+2003-12-29 Roger Sayle <roger@eyesopen.com>
+
+ PR fortran/12632
+ * g77.dg/12632.f: New test case.
+
+2003-12-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/13289
+ * g++.dg/parse/nontype1.C: New test.
+
+2003-12-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/12403
+ * g++.dg/parse/explicit1.C: New test.
+ * g++.old-deja/g++.pt/explicit71.C: Adjust expected error.
+
+2003-12-28 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/13081
+ * g++.dg/opt/inline6.C: New test.
+
+ PR c++/12613
+ * g++.dg/parse/error9.C: New test.
+
+ * gcc.dg/const-elim-1.c: XFAIL on arm-*-*.
+
+2003-12-28 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/13009
+ * g++.dg/init/assign1.C: New test.
+
+2003-12-28 Roger Sayle <roger@eyesopen.com>
+
+ PR c++/13070
+ * g++.dg/warn/format3.C: New test case.
+
+2003-12-27 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
+
+ * gcc.c-torture/compile/20031227-1.c: New test.
+
+2003-12-23 Mark Mitchell <mark@codesourcery.com>
+
+ * g++.dg/bprob/bprob.exp: Load target-supports.exp
+ * g77.dg/bprob/bprob.exp: Likewise.
+ * gcc.misc-tests/bprob.exp: Likewise.
+ * gcc.dg/builtins-18.c: Use builtins-config.h. Do not test float
+ variants on systems where the library does not provide that
+ functionality.
+ * gcc.dg/builtins-20.c: Use builtins-config.h.
+ * gcc.dg/builtins-config.h: New file.
+
+2003-12-23 Mark Mitchell <mark@codesourcery.com>
+
+ * lib/gcc-dg.exp (dg-require-profiling): New function.
+ * lib/target-supports.exp (check_profiling_available): Likewise.
+ * g++.dg/bprob/bprob.exp: Use check_profiling_available.
+ * g77.dg/bprob/bprob.exp: Likewise.
+ * gcc.misc-tests/bprob.exp: Likewise.
+ * g++.old-deja/g++.law/profile1.C: Use dg-require-profiling.
+ * gcc.dg/20021014-1.c: Likewise.
+ * gcc.dg/nest.c: Likewise.
+
+2003-12-23 Mark Mitchell <mark@codesourcery.com>
+
+ * g++.dg/lookup/java1.C: Use -fdollars-in-identifiers when
+ compiling.
+ * g++.dg/lookup/java2.C: Likewise.
+ * gcc.dg/cpp/lexident.c: Likewise.
+
+2003-12-23 Kazu Hirata <kazu@cs.umass.edu>
+
+ * gcc.c-torture/compile/20020604-1.c: XFAIL on H8 if -mn is
+ given.
+ * gcc.c-torture/compile/961203-1.c: Likewise.
+ * gcc.c-torture/compile/980506-1.c: Likewise.
+
+2003-12-23 Zack Weinberg <zack@codesourcery.com>
+
+ * lib/gcc-dg.exp (dg-prune-output): New annotation.
+ (additional_prunes): New global.
+ (gcc-dg-prune): Handle additional per-test pruning.
+ (dg-test): Clear additional_prunes between tests.
+
+ * gcc.c-torture/compile/920625-1.c: Remove xfail. Use
+ dg-prune-output to avoid spurious failures from assembler
+ complaining about nonexistent WAW violations.
+ * gcc.c-torture/compile/981223-1.c: Remove dg-options line.
+ Use dg-prune-output to avoid spurious failures from assembler
+ warning about Itanium B-step errata.
+
2003-12-23 Mark Mitchell <mark@codesourcery.com>
* g++.dg/abi/macro0.C: New test.
@@ -350,7 +476,7 @@
* g++.dg/template/type1.C: Likewise.
* g++.old-deja/g++.other/crash32.C: Likewise.
* g++.old-djea/g++.pt/defarg8.C: Likewise.
-
+
2003-12-14 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/13106
diff --git a/gcc/testsuite/g++.dg/abi/vbase10.C b/gcc/testsuite/g++.dg/abi/vbase10.C
index 7683250ea5d..bd03105ec1d 100644
--- a/gcc/testsuite/g++.dg/abi/vbase10.C
+++ b/gcc/testsuite/g++.dg/abi/vbase10.C
@@ -3,5 +3,11 @@
struct A { virtual void f(); char c1; };
struct B { B(); char c2; };
-struct C : public A, public virtual B {}; // { dg-warning "ABI" }
+// On ARM processors, the alignment of B will be 4 even though it
+// contains only a single "char". That avoids the situation that the
+// warning below is designed to catch. On ARM NetBSD, the alignment
+// of B will be only 1 -- but there is no way to tell DejaGNU that a
+// failure is expected on all ARM targets except arm*-*-netbsd*.
+// Therefore, this test will XPASS on arm*-*-netbsd*.
+struct C : public A, public virtual B {}; // { dg-warning "ABI" "" { xfail arm*-*-* } }
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C b/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C
index a52ec2e865e..01a2ec696db 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C
@@ -1,4 +1,4 @@
-// { dg-do run { xfail m68k-motorola-sysv m88k-motorola-sysv3 } }
+// { dg-do run }
// { dg-options "-fPIC" }
// Test that non-variadic function calls using thunks and PIC work right.
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C b/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C
index 9a4cffcdc56..8b8104969a3 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C
@@ -1,4 +1,4 @@
-// { dg-do run { xfail mips*-*-* rs6000-*-* powerpc-*-eabi m68k-*-coff m68k-motorola-sysv m88k-motorola-sysv3 mn10300-*-* mn10200-*-* v850-*-* sh-*-* sh64-*-* h8*-*-* xtensa-*-* } }
+// { dg-do run { xfail mips*-*-* rs6000-*-* powerpc-*-eabi m68k-*-coff mn10300-*-* v850-*-* sh-*-* sh64-*-* h8*-*-* xtensa-*-* } }
// Test that variadic function calls using thunks work right.
// Note that this will break on any target that uses the generic thunk
// support, because it doesn't support variadic functions.
diff --git a/gcc/testsuite/g++.old-deja/g++.law/profile1.C b/gcc/testsuite/g++.old-deja/g++.law/profile1.C
index 0a03bff6e80..9ca4a915469 100644
--- a/gcc/testsuite/g++.old-deja/g++.law/profile1.C
+++ b/gcc/testsuite/g++.old-deja/g++.law/profile1.C
@@ -1,4 +1,4 @@
-// { dg-do run { xfail m68k-motorola-sysv m88k-motorola-sysv3 mips*-*-* i[3456]86-*-sco3.2v5* } }
+// { dg-do run { xfail mips*-*-* i[3456]86-*-sco3.2v5* } }
// { dg-require-profiling "" }
// { dg-options "-pg" }
// { dg-options "-pg -static" { target hppa*-*-hpux* } }
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C
index 25ba9ff564c..03b879433b5 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C
@@ -12,4 +12,4 @@ class bug {
};
template <class X>
template <> // { dg-error "" } invalid specialization
-class bug<X>::a<char> {};
+class bug<X>::a<char> {}; // { dg-error "" }
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020604-1.c b/gcc/testsuite/gcc.c-torture/compile/20020604-1.c
index 488a1b403d3..ef24e1cf139 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20020604-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20020604-1.c
@@ -1,5 +1,5 @@
/* The array is too big. */
-/* { dg-xfail-if "The array too big" { "h8300-*-*" } { "-mno-h" } { "" } } */
+/* { dg-xfail-if "The array too big" { "h8300-*-*" } { "-mno-h" "-mn" } { "" } } */
/* { dg-do assemble { xfail m6811-*-* m6812-*-* } } */
/* PR c/6957
diff --git a/gcc/testsuite/gcc.c-torture/compile/920625-1.c b/gcc/testsuite/gcc.c-torture/compile/920625-1.c
index 137e0dc1f17..6a52b029bad 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920625-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920625-1.c
@@ -11,7 +11,11 @@
(p7) mov r14 = r0
that appears to be a WAW violation. */
-/* { dg-xfail-if "missing .pred.rel.mutex directive" "ia64-*-*" { "-O1" "-O2" "-O3" "-Os" } { "" } } */
+
+/* { dg-prune-output "Assembler messages" } */
+/* { dg-prune-output "violate\[^\n\]*dependency" } */
+/* { dg-prune-output "first path encountering" } */
+/* { dg-prune-output "location of the conflicting" } */
typedef unsigned long int unsigned_word;
typedef signed long int signed_word;
diff --git a/gcc/testsuite/gcc.c-torture/compile/961203-1.c b/gcc/testsuite/gcc.c-torture/compile/961203-1.c
index 1d879292e51..40cac8e3d05 100644
--- a/gcc/testsuite/gcc.c-torture/compile/961203-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/961203-1.c
@@ -1,6 +1,6 @@
/* The structure is too large for the xstormy16 - won't fit in 16
bits. */
-/* { dg-xfail-if "The array too big" { "h8300-*-*" } { "-mno-h" } { "" } } */
+/* { dg-xfail-if "The array too big" { "h8300-*-*" } { "-mno-h" "-mn" } { "" } } */
/* { dg-do assemble { xfail xstormy16-*-* m6811-*-* m6812-*-* } } */
struct s {
diff --git a/gcc/testsuite/gcc.c-torture/compile/980506-1.c b/gcc/testsuite/gcc.c-torture/compile/980506-1.c
index fd3496af309..9bc2d8afc3e 100644
--- a/gcc/testsuite/gcc.c-torture/compile/980506-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/980506-1.c
@@ -1,5 +1,5 @@
/* The arrays are too large for the xstormy16 - won't fit in 16 bits. */
-/* { dg-xfail-if "The array too big" { "h8300-*-*" } { "-mno-h" } { "" } } */
+/* { dg-xfail-if "The array too big" { "h8300-*-*" } { "-mno-h" "-mn" } { "" } } */
/* { dg-do assemble { xfail xstormy16-*-* m6811-*-* m6812-*-* } } */
unsigned char TIFFFax2DMode[20][256];
diff --git a/gcc/testsuite/gcc.c-torture/compile/981006-1.c b/gcc/testsuite/gcc.c-torture/compile/981006-1.c
index d71637328db..718fa881af5 100644
--- a/gcc/testsuite/gcc.c-torture/compile/981006-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/981006-1.c
@@ -6,7 +6,7 @@
/* { dg-do assemble } */
/* For MIPS at least, pic is needed to trigger the problem. */
/* { dg-options "-w -Wuninitialized -Werror -fpic" } */
-/* { dg-options "-w -Wuninitialized -Werror" { target rs6000-*-aix* powerpc*-*-aix* arm*-*-* xscale*-*-* strongarm*-*-* fr30-*-* sh-*-hms sh-*-coff h8300*-*-* mn10200*-*-* cris-*-elf* cris-*-aout* mmix-*-* } } */
+/* { dg-options "-w -Wuninitialized -Werror" { target rs6000-*-aix* powerpc*-*-aix* arm*-*-* xscale*-*-* strongarm*-*-* fr30-*-* sh-*-hms sh-*-coff h8300*-*-* cris-*-elf* cris-*-aout* mmix-*-* } } */
int foo (int a, int b)
{
diff --git a/gcc/testsuite/gcc.c-torture/compile/981223-1.c b/gcc/testsuite/gcc.c-torture/compile/981223-1.c
index d0939f62eaf..b6289480749 100644
--- a/gcc/testsuite/gcc.c-torture/compile/981223-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/981223-1.c
@@ -1,11 +1,11 @@
/* The problem on IA-64 is that the assembler emits
Warning: Additional NOP may be necessary to workaround Itanium
- processor A/B step errata
+ processor A/B step errata */
+
+/* { dg-prune-output "Assembler messages" } */
+/* { dg-prune-output "Additional NOP may be necessary" } */
- This can be fixed by adding "-mb-step" to the command line, which
- does in fact add the extra nop. */
-/* { dg-options "-w -mb-step" { target ia64-*-* } } */
__complex__ float
func (__complex__ float x)
diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2e.x b/gcc/testsuite/gcc.c-torture/execute/loop-2e.x
index d7b9f285097..9836850d8b2 100644
--- a/gcc/testsuite/gcc.c-torture/execute/loop-2e.x
+++ b/gcc/testsuite/gcc.c-torture/execute/loop-2e.x
@@ -1,11 +1,4 @@
-# This doesn't work on m68k-motorola-sysv
-# It also doesn't work on m88k-motorola-sysv3
-
global target_triplet
-if { [istarget "m68k-motorola-sysv"] || [istarget "m88k-motorola-sysv3"] } {
- set torture_compile_xfail "$target_triplet"
-}
-
if { [istarget "i?86-*"] } {
set torture_eval_before_execute {
global compiler_conditional_xfail_data
diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2f.x b/gcc/testsuite/gcc.c-torture/execute/loop-2f.x
deleted file mode 100644
index e68b8fbb8d2..00000000000
--- a/gcc/testsuite/gcc.c-torture/execute/loop-2f.x
+++ /dev/null
@@ -1,9 +0,0 @@
-# This doesn't work on m68k-motorola-sysv
-# It also doesn't work on m88k-motorola-sysv3
-
-global target_triplet
-if { [istarget "m68k-motorola-sysv"] || [istarget "m88k-motorola-sysv3"] } {
- set torture_compile_xfail "$target_triplet"
-}
-
-return 0
diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2g.x b/gcc/testsuite/gcc.c-torture/execute/loop-2g.x
deleted file mode 100644
index e68b8fbb8d2..00000000000
--- a/gcc/testsuite/gcc.c-torture/execute/loop-2g.x
+++ /dev/null
@@ -1,9 +0,0 @@
-# This doesn't work on m68k-motorola-sysv
-# It also doesn't work on m88k-motorola-sysv3
-
-global target_triplet
-if { [istarget "m68k-motorola-sysv"] || [istarget "m88k-motorola-sysv3"] } {
- set torture_compile_xfail "$target_triplet"
-}
-
-return 0
diff --git a/gcc/testsuite/gcc.c-torture/execute/strct-varg-1.x b/gcc/testsuite/gcc.c-torture/execute/strct-varg-1.x
deleted file mode 100644
index 850736e82dc..00000000000
--- a/gcc/testsuite/gcc.c-torture/execute/strct-varg-1.x
+++ /dev/null
@@ -1,7 +0,0 @@
-# This doesn't work on mn10200
-
-if { [istarget "mn10200*-*-*"] } {
- set torture_execute_xfail "mn10200*-*-*"
-}
-
-return 0
diff --git a/gcc/testsuite/gcc.dg/20020312-2.c b/gcc/testsuite/gcc.dg/20020312-2.c
index 082190b3c36..c6b9d8e26fa 100644
--- a/gcc/testsuite/gcc.dg/20020312-2.c
+++ b/gcc/testsuite/gcc.dg/20020312-2.c
@@ -40,8 +40,6 @@
/* No pic register. */
#elif defined(__m68k__)
# define PIC_REG "a5"
-#elif defined(__m88k__)
-# define PIC_REG "25"
#elif defined(__mc68hc1x__)
/* No pic register. */
#elif defined(__mcore__)
@@ -50,8 +48,6 @@
/* PIC register is $28, but is used even without -fpic. */
#elif defined(__MMIX__)
/* No pic register. */
-#elif defined(__mn10200__)
-/* No pic register. */
#elif defined(__mn10300__)
/* No pic register. */
#elif #cpu(ns32k)
@@ -66,8 +62,6 @@
# else
# define PIC_REG "30"
# endif
-#elif defined(__ibm032__) /* aka romp */
-/* No pic register. */
#elif defined(__s390__)
# define PIC_REG "12"
#elif defined(__sparc__)
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 85296d9145b..c6776679389 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -130,8 +130,17 @@ proc gcc-dg-test { prog do_what extra_tool_flags } {
}
proc gcc-dg-prune { system text } {
+ global additional_prunes
+
set text [prune_gcc_output $text]
+ foreach p $additional_prunes {
+ if { [string length $p] > 0 } {
+ # Following regexp matches a complete line containing $p.
+ regsub -all "(^|\n)\[^\n\]*$p\[^\n\]*" $text "" text
+ }
+ }
+
# If we see "region xxx is full" then the testcase is too big for ram.
# This is tricky to deal with in a large testsuite like c-torture so
# deal with it here. Just mark the testcase as unsupported.
@@ -339,6 +348,18 @@ proc dg-require-dll { args } {
set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
}
+# Prune any messages matching ARGS[1] (a regexp) from test output.
+proc dg-prune-output { args } {
+ global additional_prunes
+
+ if { [llength $args] != 2 } {
+ error "[lindex $args 1]: need one argument"
+ return
+ }
+
+ lappend additional_prunes [lindex $args 1]
+}
+
# Like check_conditional_xfail, but callable from a dg test.
proc dg-xfail-if { args } {
@@ -351,11 +372,10 @@ proc dg-xfail-if { args } {
}
-# We need to make sure that additional_files and additional_sources
-# are both cleared out after every test. It is not enough to clear
-# them out *before* the next test run because gcc-target-compile gets
-# run directly from some .exp files (outside of any test). (Those
-# uses should eventually be eliminated.)
+# We need to make sure that additional_* are cleared out after every
+# test. It is not enough to clear them out *before* the next test run
+# because gcc-target-compile gets run directly from some .exp files
+# (outside of any test). (Those uses should eventually be eliminated.)
# Because the DG framework doesn't provide a hook that is run at the
# end of a test, we must replace dg-test with a wrapper.
@@ -366,15 +386,19 @@ if { [info procs saved-dg-test] == [list] } {
proc dg-test { args } {
global additional_files
global additional_sources
+ global additional_prunes
global errorInfo
if { [ catch { eval saved-dg-test $args } errmsg ] } {
set saved_info $errorInfo
set additional_files ""
set additional_sources ""
+ set additional_prunes ""
error $errmsg $saved_info
}
set additional_files ""
set additional_sources ""
+ set additional_prunes ""
}
}
+set additional_prunes ""
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 7d01eb6dc1c..6e34c6d6c06 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2477,6 +2477,7 @@ rest_of_handle_branch_prob (tree decl, rtx insns)
estimate_probability (&loops);
flow_loops_free (&loops);
+ free_dominance_info (CDI_DOMINATORS);
close_dump_file (DFI_bp, print_rtl_with_bb, insns);
timevar_pop (TV_BRANCH_PROB);
}
@@ -2975,7 +2976,7 @@ rest_of_handle_loop_optimize (tree decl, rtx insns)
free_bb_for_insn ();
if (flag_unroll_loops)
- do_unroll = 0; /* Having two unrollers is useless. */
+ do_unroll = LOOP_AUTO_UNROLL; /* Having two unrollers is useless. */
else
do_unroll = flag_old_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL;
do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0;
@@ -3014,8 +3015,9 @@ rest_of_handle_loop_optimize (tree decl, rtx insns)
sooner, but we want the profile feedback to work more
efficiently. */
static void
-rest_of_handle_loop2 (tree decl, rtx insns)
+rest_of_handle_loop2 (tree decl ATTRIBUTE_UNUSED, rtx insns ATTRIBUTE_UNUSED)
{
+#if 0
struct loops *loops;
timevar_push (TV_LOOP);
open_dump_file (DFI_loop2, decl);
@@ -3047,6 +3049,7 @@ rest_of_handle_loop2 (tree decl, rtx insns)
close_dump_file (DFI_loop2, print_rtl_with_bb, get_insns ());
timevar_pop (TV_LOOP);
ggc_collect ();
+#endif
}
/* This is called from finish_function (within langhooks.parse_file)
@@ -4352,10 +4355,6 @@ process_options (void)
else if (write_symbols == SDB_DEBUG)
debug_hooks = &sdb_debug_hooks;
#endif
-#ifdef DWARF_DEBUGGING_INFO
- else if (write_symbols == DWARF_DEBUG)
- debug_hooks = &dwarf_debug_hooks;
-#endif
#ifdef DWARF2_DEBUGGING_INFO
else if (write_symbols == DWARF2_DEBUG)
debug_hooks = &dwarf2_debug_hooks;
diff --git a/gcc/version.c b/gcc/version.c
index 52d8504a776..1a80818ff5e 100644
--- a/gcc/version.c
+++ b/gcc/version.c
@@ -5,7 +5,7 @@
please modify this string to indicate that, e.g. by putting your
organization's name in parentheses at the end of the string. */
-const char version_string[] = "3.4.0 20031223 (experimental)";
+const char version_string[] = "3.4.0 20031230 (experimental)";
/* This is the location of the online document giving instructions for
reporting bugs. If you distribute a modified version of GCC,
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index f774b6265ce..a9dc46ddde5 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,7 @@
+2003-12-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * cp-demangle.c (is_ctor_or_dtor): Fix error in last change.
+
2003-12-23 Zack Weinberg <zack@codesourcery.com>
Nathan Sidwell <nathan@codesourcery.com>
Mark Mitchell <mark@codesourcery.com>
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index b54cbe2bc31..16871abaad3 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -4085,8 +4085,7 @@ is_ctor_or_dtor (mangled, ctor_kind, dtor_kind)
free (di.comps);
if (di.subs != NULL)
free (di.subs);
- *palc = 1;
- return NULL;
+ return 0;
}
#endif
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index c6da6ab4c16..9211c7c91f6 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,213 @@
+2003-12-30 Michael Koch <konqueror@gmx.de>
+
+ * java/io/ObjectInputStream.java,
+ java/io/ObjectOutputStream.java,
+ java/io/ObjectStreamClass.java:
+ Reformated, no functional code changes.
+
+2003-12-30 Michael Koch <konqueror@gmx.de>
+
+ * gnu/java/net/protocol/http/Connection.java
+ (outputStream): New field.
+ (bufferedOutputStream): New field.
+ (connect): Initialize outputStream and bufferedOutputStream.
+ (sendRequest): Create PrintWriter object from outputStream,
+ support HTTP 1.1, send missing HTTP headers and buffered output data
+ for POST method.
+ (getOutputStream): Set request method to POST if output stream is
+ used, return bufferedOutputStream.
+ (setRequestMethod): Allow HEAD and POST methods.
+ This fixes libgcj PR/6302 and libgcj PR/7752.
+
+2003-12-30 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * java/io/LineNumberReader.java
+ (countLines): Removed.
+ (fill): New private method.
+ (mark): Changed logic to use and matchedNewLine.
+ (reset): Likewise.
+ (read): Likewise.
+ (skipRedundantLF): Likewise.
+
+2003-12-30 Michael Koch <konqueror@gmx.de>
+
+ * gnu/java/net/protocol/http/Connection.java
+ (requestProperties): New field.
+ (addRequestProperty): New method.
+ (getRequestProperty): New method.
+ (setRequestProperty): New method.
+ (getRequestProperties): New method.
+
+2003-12-28 Michael Koch <konqueror@gmx.de>
+
+ * gnu/java/net/protocol/http/Connection.java
+ (inputStream): Made it a DataInputStream.
+ (requestProperties): Removed.
+ (hdrHash): Removed.
+ (hdrVec): Removed.
+ (headers): New field to store headers.
+ (connect): Initialize inputStream.
+ (receiveReply): Merged from classpath. The new algorithm is line based
+ instead of character based.
+ (getHeaderField): Use headers.
+ (getHeaderFields): Use headers.
+ (getKey): Removed.
+ (getField): Removed.
+ * gnu/java/net/HeaderFieldHelper.java: New file.
+ * Makefile.am (ordinary_java_source_files):
+ Added gnu/java/net/HeaderFieldHelper.java.
+ * Makefile.in: Regenerated.
+
+2003-12-28 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * java/io/LineNumberReader.java
+ (mark): Improved error checking.
+ (read): Likewise.
+ (skip): Likewise. Skip is now really eating the specified number of
+ characters.
+ * java/io/CharArrayReader.java (read): It should throw
+ IndexOutOfBoundsException and not ArrayIndexOutOfBoundsException (see
+ mauve).
+ * java/io/BufferedReader.java (readLine): Make readLine() really block
+ until either EOF is reached or a true error happens.
+
+2003-12-27 Michael Koch <konqueror@gmx.de>
+
+ * gnu/java/net/protocol/http/Connection.java
+ (getRequestProperty): Removed.
+ (setRequestProperty): Removed.
+
+2003-12-27 Michael Koch <konqueror@gmx.de>
+
+ * gnu/java/net/protocol/http/Connection.java
+ (connect): Call receiveReply().
+ (receiveReply): Renamed from getHttpHeaders().
+ (getOutputStream): Moved check on doOutput before check for connection
+ state.
+
+2003-12-27 Michael Koch <konqueror@gmx.de>
+
+ * javax/print/attribute/ResolutionSyntax.java,
+ javax/print/attribute/SetOfIntegerSyntax.java,
+ javax/print/attribute/Size2DSyntax.java,
+ javax/print/attribute/standard/Copies.java,
+ javax/print/attribute/standard/JobImpressions.java,
+ javax/print/attribute/standard/JobMediaSheets.java,
+ javax/print/attribute/standard/NumberOfDocuments.java,
+ javax/print/attribute/standard/NumberOfInterveningJobs.java,
+ javax/print/attribute/standard/PagesPerMinute.java,
+ javax/print/attribute/standard/PagesPerMinuteColor.java,
+ javax/print/attribute/standard/QueuedJobCount.java:
+ Fixed typo (s/then/than/).
+
+2003-12-27 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * java/rmi/Naming.java (lookup): Check if the first character of the
+ filename returned by URL.getFile() is a '/', only if it is the case
+ we cut this first character and call the registry with the good name.
+ (bind): Likewise.
+ (rebind): Likewise.
+
+2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
+ Mark Wielaard <mark@klomp.org>
+
+ * java/io/BufferedReader.java (BufferedReader):
+ Throw IllegalArgumentException when size <= 0.
+ (mark): Document and better exception message for negative
+ readLimit IllegalArgumentException.
+ (read(char[],int,int)): Throw IndexOutOfBoundsException
+ if offset and count are not valid regarding buf.
+ (skip): Throw IllegalArgumentException when count is negative.
+
+2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * java/io/FileInputStream.java
+ (FileInputStream(String)): Call FileInputStream(File).
+ (FileInputStream(File)): Check whether the argument is a directory.
+
+2003-12-26 Michael Koch <konqueror@gmx.de>
+
+ * Makefile.am (rmi_java_source_files):
+ Added gnu/java/rmi/server/RMIVoidValue.java.
+ * Makefile.in: Regenerated.
+
+2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
+ Mark Wielaard <mark@klomp.org>
+
+ * gnu/java/rmi/server/UnicastConnectionManager.java
+ (startScavenger): Set the client connection manager to daemon
+ state because it may block clients until TIMEOUT is reached
+ when they are exiting.
+
+ * gnu/java/rmi/RMIVoidValue.java: New file for a class representing
+ a void return.
+
+ * gnu/java/rmi/server/UnicastRemoteCall.java
+ (DummyOutputStream): Add a boolean before each written field to
+ know whether it is a primitive.
+ (releaseOutputStream): Flush parameters at write time.
+
+ * gnu/java/rmi/server/UnicastServerRef.java
+ (incomingMessageCall): Return a RMIVoidValue if no value is to be
+ returned.
+
+ * gnu/java/rmi/server/UnicastServer.java
+ (incomingMessageCall): Do not write a returned object if it is
+ a RMIVoidValue.
+
+2003-12-25 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * libltdl/ltdl.c (HAVE_DYLD): Remove ifdef conditional for
+ darwin. Fixed by fixinclude now.
+
+2003-12-25 Michael Koch <konqueror@gmx.de>
+
+ * java/net/ServerSocket.java bind():
+ If InetSocketAddress.getAddress() returns "null" use "0.0.0.0" as
+ address to bind to.
+
+2003-12-23 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * java/io/ObjectInputStream.java
+ (getField): Handle transient and non persistent fields.
+ (readClassDescriptor): Better error handling, use the right
+ class loader.
+ (readFields): Fields marked as not present in the stream
+ or not to be set are not read and set.
+ * java/io/ObjectInputStream.java
+ (readFields): Changed implementation of GetField.
+ (readClassDescriptor): Documented.
+ * java/io/ObjectOutputStream.java
+ (writeClassDescriptor): Added condition when to write class super
+ class information.
+
+2003-12-22 Fernando Nasser <fnasser@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkChoicePeer.java (postItemEvent): Rename to...
+ (choicePostItemEvent): Change signature to more specific String object.
+ * java/awt/Choice.java (add): Generate ItemEvent for the first item
+ added.
+ (insert): Generate ItemEvent if insertion caused
+ selection to change.
+ (remove): Generate ItemEvent if removal cause selection to change.
+ (removeAll): Change algorithm to prevent generation of ItemEvents.
+ * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
+ (connect_choice_item_selectable_hook): Change argument type.
+ Fix argument value.
+ Make sure resources are feed by registering callback.
+ (Java_gnu_java_awt_peer_gtk_GtkChoicePeer_append): Adjust call to the
+ above function.
+ (Java_gnu_java_awt_peer_gtk_GtkChoicePeer_add): Ditto.
+ (item_activate): Ditto.
+ (Java_gnu_java_awt_peer_gtk_GtkChoicePeer_remove): Destroy removed
+ menuitem.
+ (item_removed): New function. Free resources.
+ * jni/gtk-peer/gtkpeer.h (item_event_hook_info): Change member type and
+ name.
+ * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
+ (Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit): Obtain MethodID for
+ choicePostItemEvent.
+
2003-12-23 Michael Koch <konqueror@gmx.de>
* javax/print/attribute/standard/Copies.java,
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index aa07b836c96..70c9cb52a2e 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -1621,6 +1621,7 @@ gnu/java/rmi/server/RMIDefaultSocketFactory.java \
gnu/java/rmi/server/RMIHashes.java \
gnu/java/rmi/server/RMIObjectInputStream.java \
gnu/java/rmi/server/RMIObjectOutputStream.java \
+gnu/java/rmi/server/RMIVoidValue.java \
gnu/java/rmi/server/UnicastConnection.java \
gnu/java/rmi/server/UnicastConnectionManager.java \
gnu/java/rmi/server/UnicastRef.java \
@@ -2237,6 +2238,7 @@ gnu/java/locale/LocaleInformation_zh_HK.java \
gnu/java/locale/LocaleInformation_zh_SG.java \
gnu/java/locale/LocaleInformation_zh_TW.java \
gnu/java/math/MPN.java \
+gnu/java/net/HeaderFieldHelper.java \
gnu/java/net/PlainDatagramSocketImpl.java \
gnu/java/net/PlainSocketImpl.java \
gnu/java/net/URLParseError.java \
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index cda9cfdea7c..9702b28a3ec 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -1336,6 +1336,7 @@ gnu/java/rmi/server/RMIDefaultSocketFactory.java \
gnu/java/rmi/server/RMIHashes.java \
gnu/java/rmi/server/RMIObjectInputStream.java \
gnu/java/rmi/server/RMIObjectOutputStream.java \
+gnu/java/rmi/server/RMIVoidValue.java \
gnu/java/rmi/server/UnicastConnection.java \
gnu/java/rmi/server/UnicastConnectionManager.java \
gnu/java/rmi/server/UnicastRef.java \
@@ -1944,6 +1945,7 @@ gnu/java/locale/LocaleInformation_zh_HK.java \
gnu/java/locale/LocaleInformation_zh_SG.java \
gnu/java/locale/LocaleInformation_zh_TW.java \
gnu/java/math/MPN.java \
+gnu/java/net/HeaderFieldHelper.java \
gnu/java/net/PlainDatagramSocketImpl.java \
gnu/java/net/PlainSocketImpl.java \
gnu/java/net/URLParseError.java \
@@ -3084,7 +3086,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/locale/LocaleInformation_zh_HK.P \
.deps/gnu/java/locale/LocaleInformation_zh_SG.P \
.deps/gnu/java/locale/LocaleInformation_zh_TW.P \
-.deps/gnu/java/math/MPN.P .deps/gnu/java/net/PlainDatagramSocketImpl.P \
+.deps/gnu/java/math/MPN.P .deps/gnu/java/net/HeaderFieldHelper.P \
+.deps/gnu/java/net/PlainDatagramSocketImpl.P \
.deps/gnu/java/net/PlainSocketImpl.P .deps/gnu/java/net/URLParseError.P \
.deps/gnu/java/net/natPlainDatagramSocketImpl.P \
.deps/gnu/java/net/natPlainSocketImpl.P \
@@ -3147,6 +3150,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/java/rmi/server/RMIHashes.P \
.deps/gnu/java/rmi/server/RMIObjectInputStream.P \
.deps/gnu/java/rmi/server/RMIObjectOutputStream.P \
+.deps/gnu/java/rmi/server/RMIVoidValue.P \
.deps/gnu/java/rmi/server/UnicastConnection.P \
.deps/gnu/java/rmi/server/UnicastConnectionManager.P \
.deps/gnu/java/rmi/server/UnicastRef.P \
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java b/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java
index c4398e5041c..7e5579b3bc7 100644
--- a/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java
+++ b/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java
@@ -84,10 +84,10 @@ public class GtkChoicePeer extends GtkComponentPeer
}
*/
- protected void postItemEvent (Object item, int stateChange)
+ protected void choicePostItemEvent (String label, int stateChange)
{
if (stateChange == ItemEvent.SELECTED)
- ((Choice) awtComponent).select ((String) item);
- super.postItemEvent (item, stateChange);
+ ((Choice) awtComponent).select (label);
+ super.postItemEvent (label, stateChange);
}
}
diff --git a/libjava/gnu/java/net/protocol/http/Connection.java b/libjava/gnu/java/net/protocol/http/Connection.java
index b564afb376f..0bc50d147c0 100644
--- a/libjava/gnu/java/net/protocol/http/Connection.java
+++ b/libjava/gnu/java/net/protocol/http/Connection.java
@@ -39,6 +39,9 @@ exception statement from your version. */
package gnu.java.net.protocol.http;
import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -48,10 +51,10 @@ import java.net.ProtocolException;
import java.net.Socket;
import java.net.URL;
import java.net.URLConnection;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Vector;
-import java.util.Hashtable;
+import gnu.java.net.HeaderFieldHelper;
/**
* This subclass of java.net.URLConnection models a URLConnection via
@@ -102,14 +105,28 @@ public final class Connection extends HttpURLConnection
/**
* The InputStream for this connection.
*/
- private BufferedInputStream inputStream;
+ private DataInputStream inputStream;
+
+ /**
+ * The OutputStream for this connection
+ */
+ private OutputStream outputStream;
+
+ /**
+ * bufferedOutputStream is a buffer to contain content of the HTTP request,
+ * and will be written to outputStream all at once
+ */
+ private ByteArrayOutputStream bufferedOutputStream;
+
+ /**
+ * This object holds the request properties.
+ */
+ private HashMap requestProperties = new HashMap();
/**
* This is the object that holds the header field information
*/
- private Hashtable requestProperties = new Hashtable();
- private Hashtable hdrHash = new Hashtable();
- private Vector hdrVec = new Vector();
+ private HeaderFieldHelper headers = new HeaderFieldHelper();
/**
* Calls superclass constructor to initialize
@@ -122,22 +139,6 @@ public final class Connection extends HttpURLConnection
doOutput = false;
}
- public void setRequestProperty(String key, String value)
- {
- if (connected)
- throw new IllegalAccessError("Connection already established.");
-
- requestProperties.put(key, value);
- }
-
- public String getRequestProperty(String key)
- {
- if (connected)
- throw new IllegalAccessError("Connection already established.");
-
- return (String) requestProperties.get(key);
- }
-
/**
* Connects to the remote host, sends the request, and parses the reply
* code and header information returned
@@ -163,16 +164,14 @@ public final class Connection extends HttpURLConnection
socket = new Socket(url.getHost(), port);
}
- // Originally tried using a BufferedReader here to take advantage of
- // the readLine method and avoid the following, but the buffer read
- // past the end of the headers so the first part of the content was lost.
- // It is probably more robust than it needs to be, e.g. the byte[]
- // is unlikely to overflow and a '\r' should always be followed by a '\n',
- // but it is better to be safe just in case.
- inputStream = new BufferedInputStream(socket.getInputStream());
+ inputStream =
+ new DataInputStream(new BufferedInputStream(socket.getInputStream()));
+ outputStream = new BufferedOutputStream (socket.getOutputStream());
+ bufferedOutputStream = new ByteArrayOutputStream (256); //default is too small
sendRequest();
- getHttpHeaders();
+ receiveReply();
+
connected = true;
}
@@ -201,16 +200,32 @@ public final class Connection extends HttpURLConnection
void sendRequest() throws IOException
{
// Create PrintWriter for easier sending of headers.
- PrintWriter outputWriter = new PrintWriter(socket.getOutputStream());
+ PrintWriter outputWriter = new PrintWriter(outputStream);
// Send request including any request properties that were set.
outputWriter.print (getRequestMethod() + " " + url.getFile()
- + " HTTP/1.0\r\n");
+ + " HTTP/1.1\r\n");
// Set additional HTTP headers.
if (getRequestProperty ("Host") == null)
setRequestProperty ("Host", url.getHost());
+ if (getRequestProperty ("Connection") == null)
+ setRequestProperty ("Connection", "Close");
+
+ if (getRequestProperty ("user-agent") == null)
+ setRequestProperty ("user-agent", "gnu-libgcj/"
+ + System.getProperty ("classpath.version"));
+
+ if (getRequestProperty ("accept") == null)
+ setRequestProperty ("accept", "*/*");
+
+ if (getRequestProperty ("Content-type") == null)
+ setRequestProperty ("Content-type", "application/x-www-form-urlencoded");
+
+ // Set correct content length.
+ setRequestProperty ("Content-length", String.valueOf (bufferedOutputStream.size()));
+
// Write all req_props name-value pairs to the output writer.
Iterator itr = getRequestProperties().entrySet().iterator();
@@ -223,6 +238,106 @@ public final class Connection extends HttpURLConnection
// One more CR-LF indicates end of header.
outputWriter.print ("\r\n");
outputWriter.flush();
+
+ // Write content
+ bufferedOutputStream.writeTo (outputStream);
+ outputStream.flush();
+ }
+
+ /**
+ * Read HTTP reply from inputStream.
+ */
+ private void receiveReply() throws IOException
+ {
+ // Parse the reply
+ String line = inputStream.readLine();
+ String saveline = line;
+ int idx = line.indexOf (" ");
+
+ if ((idx == -1)
+ || (line.length() < (idx + 6)))
+ throw new IOException ("Server reply was unparseable: " + saveline);
+
+ headers.addHeaderField (null, line);
+
+ line = line.substring (idx + 1);
+ String code = line.substring (0, 3);
+
+ try
+ {
+ responseCode = Integer.parseInt (code);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IOException ("Server reply was unparseable: " + saveline);
+ }
+
+ responseMessage = line.substring (4);
+
+ // Now read the header lines
+ String key = null, value = null;
+
+ while (true)
+ {
+ line = inputStream.readLine();
+
+ if (line.equals(""))
+ break;
+
+ // Check for folded lines
+ if (line.startsWith (" ")
+ || line.startsWith("\t"))
+ {
+ // Trim off leading space
+ do
+ {
+ if (line.length() == 1)
+ throw new IOException("Server header lines were unparseable: "
+ + line);
+
+ line = line.substring (1);
+ }
+ while (line.startsWith(" ")
+ || line.startsWith("\t"));
+
+ value = value + " " + line;
+ }
+ else
+ {
+ if (key != null)
+ {
+ headers.addHeaderField (key.toLowerCase(), value);
+ key = null;
+ value = null;
+ }
+
+ // Parse out key and value
+ idx = line.indexOf (":");
+ if ((idx == -1)
+ || (line.length() < (idx + 2)))
+ throw new IOException ("Server header lines were unparseable: "
+ + line);
+
+ key = line.substring (0, idx);
+ value = line.substring (idx + 1);
+
+ // Trim off leading space
+ while (value.startsWith (" ")
+ || value.startsWith ("\t"))
+ {
+ if (value.length() == 1)
+ throw new IOException ("Server header lines were unparseable: "
+ + line);
+
+ value = value.substring (1);
+ }
+ }
+ }
+
+ if (key != null)
+ {
+ headers.addHeaderField (key.toLowerCase(), value.toLowerCase());
+ }
}
/**
@@ -256,15 +371,23 @@ public final class Connection extends HttpURLConnection
return inputStream;
}
+ /**
+ * Returns on OutputStream for writing to this connection.
+ *
+ * @return An OutputStream for this connection.
+ *
+ * @exception IOException If an error occurs
+ */
public OutputStream getOutputStream() throws IOException
{
+ if (!doOutput)
+ throw new ProtocolException
+ ("Want output stream while haven't setDoOutput(true)");
+
if (!connected)
connect();
-
- if (! doOutput)
- throw new ProtocolException("Can't open OutputStream if doOutput is false");
- return socket.getOutputStream();
+ return bufferedOutputStream;
}
/**
@@ -279,13 +402,50 @@ public final class Connection extends HttpURLConnection
{
method = method.toUpperCase();
- if (method.equals("GET"))
+ if (method.equals("GET")
+ || method.equals("HEAD")
+ || method.equals("POST"))
super.setRequestMethod (method);
else
throw new ProtocolException ("Unsupported or unknown request method " +
method);
}
+ public void addRequestProperty(String key, String value)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ String old = (String) requestProperties.put(key, value);
+
+ if (old != null)
+ requestProperties.put(key, old + "," + value);
+ }
+
+ public String getRequestProperty(String key)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ return (String) requestProperties.get(key);
+ }
+
+ public void setRequestProperty(String key, String value)
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ requestProperties.put(key, value);
+ }
+
+ public Map getRequestProperties()
+ {
+ if (connected)
+ throw new IllegalStateException("Already connected");
+
+ return requestProperties;
+ }
+
public String getHeaderField(String name)
{
if (!connected)
@@ -298,7 +458,7 @@ public final class Connection extends HttpURLConnection
return null;
}
- return (String) hdrHash.get(name.toLowerCase());
+ return (String) headers.getHeaderFieldValueByKey(name.toLowerCase());
}
public Map getHeaderFields()
@@ -313,7 +473,7 @@ public final class Connection extends HttpURLConnection
return null;
}
- return hdrHash;
+ return headers.getHeaderFields();
}
/**
@@ -337,9 +497,7 @@ public final class Connection extends HttpURLConnection
return null;
}
- if (n < hdrVec.size())
- return getField ((String) hdrVec.elementAt(n));
- return null;
+ return headers.getHeaderFieldValueByIndex (n);
}
/**
@@ -363,86 +521,6 @@ public final class Connection extends HttpURLConnection
return null;
}
- if (n < hdrVec.size())
- return getKey ((String) hdrVec.elementAt(n));
- return null;
- }
-
- private String getKey(String str)
- {
- if (str == null)
- return null;
- int index = str.indexOf(':');
- if (index >= 0)
- return str.substring(0, index);
- else
- return null;
- }
-
- private String getField(String str)
- {
- if (str == null)
- return null;
- int index = str.indexOf(':');
- if (index >= 0)
- return str.substring(index + 1).trim();
- else
- return str;
- }
-
- /**
- * Read HTTP reply from inputStream.
- */
- private void getHttpHeaders() throws IOException
- {
- int buflen = 100;
- byte[] buf = new byte[buflen];
- String line = "";
- boolean gotnl = false;
- byte[] ch = new byte[1];
- ch[0] = (byte) '\n';
-
- while (true)
- {
- // Check for leftover byte from non-'\n' after a '\r'.
- if (ch[0] != '\n')
- line = line + '\r' + new String(ch, 0, 1);
-
- int i;
- // FIXME: This is rather inefficient.
- for (i = 0; i < buflen; i++)
- {
- buf[i] = (byte) inputStream.read();
- if (buf[i] == -1)
- throw new IOException("Malformed HTTP header");
- if (buf[i] == '\r')
- {
- inputStream.read(ch, 0, 1);
- if (ch[0] == '\n')
- gotnl = true;
- break;
- }
- }
- line = line + new String(buf, 0, i);
-
- // A '\r' '\n' combo indicates the end of the header entry.
- // If it wasn't found, cycle back through the loop and append
- // to 'line' until one is found.
- if (gotnl)
- {
- // A zero length entry signals the end of the headers.
- if (line.length() == 0)
- break;
-
- // Store the header and reinitialize for next cycle.
- hdrVec.addElement(line);
- String key = getKey(line);
- if (key != null)
- hdrHash.put(key.toLowerCase(), getField(line));
- line = "";
- ch[0] = (byte) '\n';
- gotnl = false;
- }
- }
+ return headers.getHeaderFieldKeyByIndex (n);
}
}
diff --git a/libjava/gnu/java/rmi/server/UnicastConnectionManager.java b/libjava/gnu/java/rmi/server/UnicastConnectionManager.java
index d54dcf1d4cd..3b9aa40e0b8 100644
--- a/libjava/gnu/java/rmi/server/UnicastConnectionManager.java
+++ b/libjava/gnu/java/rmi/server/UnicastConnectionManager.java
@@ -152,6 +152,9 @@ private static void startScavenger(){
if (debug) System.out.println("************* exit scavenger.");
}
});
+ // As it is used for client connection, we may put this thread
+ // in daemon state to prevent the VM from blocking when exiting.
+ scavenger.setDaemon(true);
scavenger.start();
}
diff --git a/libjava/gnu/java/rmi/server/UnicastRemoteCall.java b/libjava/gnu/java/rmi/server/UnicastRemoteCall.java
index 68d1bfe01d8..2d7d6d4a9ff 100644
--- a/libjava/gnu/java/rmi/server/UnicastRemoteCall.java
+++ b/libjava/gnu/java/rmi/server/UnicastRemoteCall.java
@@ -65,6 +65,7 @@ public class UnicastRemoteCall
private long hash;
private Vector vec;
private int ptr;
+ private ObjID objid;
private ObjectOutput oout;
private ObjectInput oin;
@@ -86,22 +87,7 @@ public class UnicastRemoteCall
this.conn = conn;
this.opnum = opnum;
this.hash = hash;
-
- // signal the call when constructing
- try
- {
- DataOutputStream dout = conn.getDataOutputStream();
- dout.write(MESSAGE_CALL);
-
- oout = conn.getObjectOutputStream();
- objid.write(oout);
- oout.writeInt(opnum);
- oout.writeLong(hash);
- }
- catch(IOException ex)
- {
- throw new MarshalException("Try to write header but failed.", ex);
- }
+ this.objid = objid;
}
UnicastConnection getConnection()
@@ -111,22 +97,43 @@ public class UnicastRemoteCall
public ObjectOutput getOutputStream() throws IOException
{
- if (conn != null)
- {
- if(oout == null)
- return (oout = conn.getObjectOutputStream());
- else
- return oout;
- }
- else
- {
- vec = new Vector();
- return (new DummyObjectOutputStream());
- }
+ if (vec == null)
+ vec = new Vector();
+ return (new DummyObjectOutputStream());
}
public void releaseOutputStream() throws IOException
{
+ if (vec != null)
+ {
+ oout = conn.getObjectOutputStream();
+
+ for (int i = 0; i < vec.size(); i += 2)
+ {
+ boolean primitive = ((Boolean)vec.elementAt(i)).booleanValue();
+ Object data = vec.elementAt(i+1);
+
+ // No type, this is
+ if (!primitive)
+ oout.writeObject(data);
+ else
+ {
+ if (data instanceof Boolean)
+ oout.writeBoolean(((Boolean)data).booleanValue());
+ else if (data instanceof Character)
+ oout.writeChar(((Character)data).charValue());
+ else if (data instanceof Byte)
+ oout.writeByte(((Byte)data).byteValue());
+ else if (data instanceof Short)
+ oout.writeShort(((Short)data).shortValue());
+ else if (data instanceof Integer)
+ oout.writeInt(((Integer)data).intValue());
+ else if (data instanceof Long)
+ oout.writeLong(((Long)data).longValue());
+ }
+ }
+ vec = null;
+ }
if(oout != null)
oout.flush();
}
@@ -163,6 +170,23 @@ public class UnicastRemoteCall
{
byte returncode;
ObjectInput oin;
+
+ // signal the call when constructing
+ try
+ {
+ DataOutputStream dout = conn.getDataOutputStream();
+ dout.write(MESSAGE_CALL);
+
+ oout = conn.getObjectOutputStream();
+ objid.write(oout);
+ oout.writeInt(opnum);
+ oout.writeLong(hash);
+ }
+ catch(IOException ex)
+ {
+ throw new MarshalException("Try to write header but failed.", ex);
+ }
+
try
{
releaseOutputStream();
@@ -211,9 +235,15 @@ public class UnicastRemoteCall
// conn.disconnect();
}
+ boolean isReturnValue()
+ {
+ return vec.size() > 0;
+ }
+
Object returnValue()
{
- return (vec.size() > 0 ? vec.elementAt(0) : null);
+ // This is not the first one (Boolean) but the second.
+ return vec.elementAt(1);
}
Object[] getArguments()
@@ -256,46 +286,55 @@ public class UnicastRemoteCall
public void writeBoolean(boolean v) throws IOException
{
- vec.addElement(new Boolean(v));
+ vec.addElement(Boolean.TRUE);
+ vec.addElement(Boolean.valueOf(v));
}
public void writeByte(int v) throws IOException
{
+ vec.addElement(Boolean.TRUE);
vec.addElement(new Byte((byte) v));
}
public void writeChar(int v) throws IOException
{
+ vec.addElement(Boolean.TRUE);
vec.addElement(new Character((char) v));
}
public void writeDouble(double v) throws IOException
{
+ vec.addElement(Boolean.TRUE);
vec.addElement(new Double(v));
}
public void writeFloat(float v) throws IOException
{
+ vec.addElement(Boolean.TRUE);
vec.addElement(new Float(v));
}
public void writeInt(int v) throws IOException
{
+ vec.addElement(Boolean.TRUE);
vec.addElement(new Integer(v));
}
public void writeLong(long v) throws IOException
{
+ vec.addElement(Boolean.TRUE);
vec.addElement(new Long(v));
}
public void writeShort(int v) throws IOException
{
+ vec.addElement(Boolean.TRUE);
vec.addElement(new Short((short) v));
}
public void writeObject(Object obj) throws IOException
{
+ vec.addElement(Boolean.FALSE);
vec.addElement(obj);
}
diff --git a/libjava/gnu/java/rmi/server/UnicastServer.java b/libjava/gnu/java/rmi/server/UnicastServer.java
index baa1ef1aa4a..fb6ec1f35a5 100644
--- a/libjava/gnu/java/rmi/server/UnicastServer.java
+++ b/libjava/gnu/java/rmi/server/UnicastServer.java
@@ -144,7 +144,7 @@ private static void incomingMessageCall(UnicastConnection conn) throws IOExcepti
(new UID()).write(out);
if(returnval != null && returncls != null)
((RMIObjectOutputStream)out).writeValue(returnval, returncls);
- else
+ else if (!(returnval instanceof RMIVoidValue))
out.writeObject(returnval);
out.flush();
diff --git a/libjava/gnu/java/rmi/server/UnicastServerRef.java b/libjava/gnu/java/rmi/server/UnicastServerRef.java
index e2f38ff5f8c..b004927502f 100644
--- a/libjava/gnu/java/rmi/server/UnicastServerRef.java
+++ b/libjava/gnu/java/rmi/server/UnicastServerRef.java
@@ -254,8 +254,11 @@ public Object incomingMessageCall(UnicastConnection conn, int method, long hash)
throw new NoSuchMethodException();
}
UnicastRemoteCall call = new UnicastRemoteCall(conn);
- skel.dispatch(myself, call, method, hash);
- return (call.returnValue());
+ skel.dispatch(myself, call, method, hash);
+ if (!call.isReturnValue())
+ return RMIVoidValue.INSTANCE;
+ else
+ return (call.returnValue());
}
}
diff --git a/libjava/java/awt/Choice.java b/libjava/java/awt/Choice.java
index 0b5e3d61dad..863888c5b37 100644
--- a/libjava/java/awt/Choice.java
+++ b/libjava/java/awt/Choice.java
@@ -171,7 +171,15 @@ add(String item)
}
if (i == 0)
- select (0);
+ {
+ selectedIndex = 0;
+ // We must generate an ItemEvent here
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent (
+ new ItemEvent ((ItemSelectable)this,
+ ItemEvent.ITEM_STATE_CHANGED,
+ getItem(0),
+ ItemEvent.SELECTED));
+ }
}
/*************************************************************************/
@@ -223,7 +231,15 @@ insert(String item, int index)
}
if (getItemCount () == 1 || selectedIndex >= index)
+ {
select (0);
+ // We must generate an ItemEvent here
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent (
+ new ItemEvent ((ItemSelectable)this,
+ ItemEvent.ITEM_STATE_CHANGED,
+ getItem(0),
+ ItemEvent.SELECTED));
+ }
}
/*************************************************************************/
@@ -265,8 +281,16 @@ remove(int index)
cp.remove (index);
}
- if (index == selectedIndex)
+ if ((index == selectedIndex) && (getItemCount() > 0))
+ {
select (0);
+ // We must generate an ItemEvent here
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent (
+ new ItemEvent ((ItemSelectable)this,
+ ItemEvent.ITEM_STATE_CHANGED,
+ getItem(0),
+ ItemEvent.SELECTED));
+ }
else if (selectedIndex > index)
--selectedIndex;
}
@@ -281,11 +305,27 @@ removeAll()
{
int count = getItemCount();
- for (int i = 0; i < count; i++)
+ if (count <= 0)
+ return;
+
+ ChoicePeer cp = (ChoicePeer) peer;
+
+ // Select the first item to prevent an spurious ItemEvent to be generated
+ if (cp != null)
+ {
+ cp.select (0);
+ selectedIndex = 0; // Just to keep consistent
+ }
+
+ for (int i = (count - 1); i >= 0; i--)
{
- // Always remove 0.
- remove(0);
+ // Always remove the last to avoid generation of ItemEvents.
+ pItems.removeElementAt(i);
+ if (cp != null)
+ cp.remove (i);
}
+
+ selectedIndex = -1;
}
/*************************************************************************/
diff --git a/libjava/java/io/BufferedReader.java b/libjava/java/io/BufferedReader.java
index 46c9e417b1b..e29c8dd8844 100644
--- a/libjava/java/io/BufferedReader.java
+++ b/libjava/java/io/BufferedReader.java
@@ -106,10 +106,14 @@ public class BufferedReader extends Reader
*
* @param in The subordinate stream to read from
* @param size The buffer size to use
+ *
+ * @exception IllegalArgumentException if size &lt;&eq; 0
*/
public BufferedReader(Reader in, int size)
{
super(in.lock);
+ if (size <= 0)
+ throw new IllegalArgumentException("Illegal buffer size: " + size);
this.in = in;
buffer = new char[size];
}
@@ -161,11 +165,12 @@ public class BufferedReader extends Reader
* becomes invalid
*
* @exception IOException If an error occurs
+ * @exception IllegalArgumentException if readLimit is negative.
*/
public void mark(int readLimit) throws IOException
{
if (readLimit < 0)
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Read-ahead limit is negative");
synchronized (lock)
{
@@ -280,9 +285,14 @@ public class BufferedReader extends Reader
* @return The actual number of chars read, or -1 if end of stream.
*
* @exception IOException If an error occurs.
+ * @exception IndexOutOfBoundsException If offset and count are not
+ * valid regarding buf.
*/
public int read(char[] buf, int offset, int count) throws IOException
{
+ if (offset < 0 || offset + count > buf.length || count < 0)
+ throw new IndexOutOfBoundsException();
+
synchronized (lock)
{
checkStatus();
@@ -450,12 +460,19 @@ public class BufferedReader extends Reader
boolean eof = false;
for (;;)
{
- int ch = read();
- if (ch < 0)
+ // readLine should block. So we must not return until a -1 is reached.
+ if (pos >= limit)
{
- eof = true;
- break;
+ // here count == 0 isn't sufficient to give a failure.
+ int count = fill();
+ if (count < 0)
+ {
+ eof = true;
+ break;
+ }
+ continue;
}
+ int ch = buffer[pos++];
if (ch == '\n' || ch == '\r')
{
// Check here if a '\r' was the last char in the buffer; if so,
@@ -487,14 +504,17 @@ public class BufferedReader extends Reader
*
* @return The actual number of chars skipped.
*
- * @exception IOException If an error occurs
+ * @exception IOException If an error occurs.
+ * @exception IllegalArgumentException If count is negative.
*/
public long skip(long count) throws IOException
{
synchronized (lock)
{
checkStatus();
- if (count <= 0)
+ if (count < 0)
+ throw new IllegalArgumentException("skip value is negative");
+ if (count == 0)
return 0;
// Yet again, we need to handle the special case of a readLine
// that has a '\r' at the end of the buffer. In this case, we need
diff --git a/libjava/java/io/CharArrayReader.java b/libjava/java/io/CharArrayReader.java
index f379519b834..9d5382bef1e 100644
--- a/libjava/java/io/CharArrayReader.java
+++ b/libjava/java/io/CharArrayReader.java
@@ -228,7 +228,7 @@ public class CharArrayReader extends Reader
/* Don't need to check pos value, arraycopy will check it. */
if (off < 0 || len < 0 || off + len > b.length)
- throw new ArrayIndexOutOfBoundsException();
+ throw new IndexOutOfBoundsException();
if (pos >= count)
return -1;
diff --git a/libjava/java/io/FileInputStream.java b/libjava/java/io/FileInputStream.java
index 4c599d11d1b..c88f83db445 100644
--- a/libjava/java/io/FileInputStream.java
+++ b/libjava/java/io/FileInputStream.java
@@ -79,11 +79,7 @@ public class FileInputStream extends InputStream
*/
public FileInputStream(String name) throws FileNotFoundException
{
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkRead(name);
-
- fd = new FileDescriptor(name, FileDescriptor.READ);
+ this(new File(name));
}
/**
@@ -104,7 +100,14 @@ public class FileInputStream extends InputStream
*/
public FileInputStream(File file) throws FileNotFoundException
{
- this(file.getPath());
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkRead(file.getPath());
+
+ if (file.isDirectory())
+ throw new FileNotFoundException(file.getPath() + " is a directory");
+
+ fd = new FileDescriptor(file.getPath(), FileDescriptor.READ);
}
/**
diff --git a/libjava/java/io/LineNumberReader.java b/libjava/java/io/LineNumberReader.java
index 9c4796d402f..b3cb5826930 100644
--- a/libjava/java/io/LineNumberReader.java
+++ b/libjava/java/io/LineNumberReader.java
@@ -54,7 +54,8 @@ package java.io;
*
* @author Per Bothner <bothner@cygnus.com>
* @author Aaron M. Renn (arenn@urbanophile.com)
- * @date April 22, 1998.
+ * @author Guilhem Lavaux <guilhem@kaffe.org>
+ * @date December 28, 2003.
*/
/* Written using "Java Class Libraries", 2nd edition, plus online
* API docs for JDK 1.2 beta from http://www.javasoft.com.
@@ -71,6 +72,10 @@ public class LineNumberReader extends BufferedReader
{
/** The current line number. */
private int lineNumber;
+ /** Whether we already found a new line in the former call. */
+ private boolean matchedNewLine;
+ /** The saved line number when calling mark() */
+ private int savedLineNumber;
/**
* Create a new <code>LineNumberReader</code> that reads from the
@@ -117,20 +122,6 @@ public class LineNumberReader extends BufferedReader
this.lineNumber = lineNumber;
}
- private static int countLines (char[] buffer, int off, int len)
- {
- int count = 0;
- char prev = '\0';
- for (int i = 0; i < len; i++)
- {
- char ch = buffer[i+off];
- if ((ch == '\n' && prev != '\r') || ch == '\r')
- count++;
- prev = ch;
- }
- return count;
- }
-
/**
* This method marks a position in the input to which the stream can be
* "reset" char calling the <code>reset()</code> method. The parameter
@@ -155,6 +146,9 @@ public class LineNumberReader extends BufferedReader
*/
public void mark(int readLimit) throws IOException
{
+ if (readLimit < 0)
+ throw new IllegalArgumentException("Read-ahead limit is negative");
+
synchronized (lock)
{
// This is basically the same as BufferedReader.mark.
@@ -162,11 +156,12 @@ public class LineNumberReader extends BufferedReader
// save that 'r', in case the next character is a '\n'.
if (pos + readLimit > limit)
{
- int saveCR = (pos > 0 && buffer[pos-1] == '\r') ? 1 : 0;
+ int saveCR = matchedNewLine ? 1 : 0;
char[] old_buffer = buffer;
if (readLimit > limit)
buffer = new char[saveCR + readLimit];
int copy_start = pos - saveCR;
+ savedLineNumber = lineNumber;
limit -= copy_start;
System.arraycopy(old_buffer, copy_start, buffer, 0, limit);
pos = saveCR;
@@ -192,15 +187,35 @@ public class LineNumberReader extends BufferedReader
{
if (markPos < 0)
throw new IOException("mark never set or invalidated");
- if (markPos > 0 && pos > markPos && buffer[markPos-1] == '\r'
- && buffer[markPos] == '\n')
- lineNumber--;
- lineNumber -= countLines(buffer, markPos, pos - markPos);
+ lineNumber = savedLineNumber;
pos = markPos;
+ matchedNewLine = (markPos > 0 && buffer[markPos-1] == '\r');
}
}
/**
+ * This private method fills the input buffer whatever pos is.
+ * Consequently pos should be checked before calling this method.
+ *
+ * @return the number of bytes actually read from the input stream or
+ * -1 if end of stream.
+ * @exception IOException If an error occurs.
+ */
+ private int fill() throws IOException
+ {
+ if (markPos >= 0 && limit == buffer.length)
+ markPos = -1;
+ if (markPos < 0)
+ pos = limit = 0;
+ int count = in.read(buffer, limit, buffer.length - limit);
+ if (count <= 0)
+ return -1;
+ limit += count;
+
+ return count;
+ }
+
+ /**
* This method reads an unsigned char from the input stream and returns it
* as an int in the range of 0-65535. This method will return -1 if the
* end of the stream has been reached.
@@ -223,30 +238,24 @@ public class LineNumberReader extends BufferedReader
synchronized (lock)
{
skipRedundantLF();
- if (pos >= limit)
- {
- if (markPos >= 0 && limit == buffer.length)
- markPos = -1;
- if (markPos < 0)
- pos = limit = 0;
- int count = in.read(buffer, limit, buffer.length - limit);
- if (count <= 0)
- return -1;
- limit += count;
- }
+ if (pos >= limit && fill() < 0)
+ return -1;
char ch = buffer[pos++];
- if (ch == '\r' || ch == '\n')
+
+ if ((matchedNewLine = (ch == '\r')) || ch == '\n')
{
lineNumber++;
return '\n';
}
+ matchedNewLine = false;
return (int) ch;
}
}
/**
* This method reads chars from a stream and stores them into a caller
- * supplied buffer. It starts storing data at index <code>offset</code> into * the buffer and attemps to read <code>len</code> chars. This method can
+ * supplied buffer. It starts storing data at index <code>offset</code> into
+ * the buffer and attemps to read <code>len</code> chars. This method can
* return before reading the number of chars requested. The actual number
* of chars read is returned as an int. A -1 is returned to indicated the
* end of the stream.
@@ -265,46 +274,57 @@ public class LineNumberReader extends BufferedReader
* @return The actual number of chars read, or -1 if end of stream
*
* @exception IOException If an error occurs.
+ * @exception NullPointerException If buf is null (in any case).
+ * @exception IndexOutOfBoundsException If buffer parameters (offset and
+ * count) lies outside of the buffer capacity.
*/
public int read(char[] buf, int offset, int count) throws IOException
{
+ if (buf == null)
+ throw new NullPointerException();
+
+ if (offset + count > buf.length || offset < 0)
+ throw new IndexOutOfBoundsException();
+
if (count <= 0)
{
if (count < 0)
throw new IndexOutOfBoundsException();
return 0;
}
+
synchronized (lock)
{
- int first = read();
- if (first < 0)
+ if (pos >= limit && fill() < 0)
return -1;
+
int start_offset = offset;
- buf[offset++] = (char) first;
- if (buffer[pos-1] == '\r' && pos < limit && buffer[pos] == '\n')
- pos++;
- count--;
+ boolean matched = matchedNewLine;
+
while (count-- > 0 && pos < limit)
{
char ch = buffer[pos++];
if (ch == '\r')
{
lineNumber++;
- ch = '\n';
- if (pos < limit && buffer[pos] == '\n')
- pos++;
+ matched = true;
}
- else if (ch == '\n')
+ else if (ch == '\n' && !matched)
lineNumber++;
+ else
+ matched = false;
+
buf[offset++] = ch;
}
+
+ matchedNewLine = matched;
return offset - start_offset;
}
}
private void skipRedundantLF() throws IOException
{
- if (pos > 0 && buffer[pos-1] == '\r')
+ if (pos > 0 && matchedNewLine)
{
if (pos < limit)
{ // fast case
@@ -312,16 +332,14 @@ public class LineNumberReader extends BufferedReader
pos++;
}
else
- { // use read() to deal with the general case.
- // Set pos and limit to zero to avoid infinite recursion in read.
- // May need to invalidate markPos if we've exceeded the buffer.
- if (pos >= buffer.length)
- markPos = -1;
- pos = limit = 0;
- int ch = read();
- if (ch >= 0 && ch != '\n')
- pos--;
+ { // check whether the next buffer begins with '\n'.
+ // in that case kill the '\n'.
+ if (fill() <= 0)
+ return;
+ if (buffer[pos] == '\n')
+ pos++;
}
+ matchedNewLine = true;
}
}
@@ -355,8 +373,9 @@ public class LineNumberReader extends BufferedReader
if (pos > limit)
--pos;
- int ch;
- if (pos > 0 && ((ch = buffer[pos - 1]) == '\n' || ch == '\r'))
+ // The only case where you mustn't increment the line number is you are
+ // at the EOS.
+ if (str != null)
lineNumber = tmpLineNumber + 1;
return str;
@@ -376,14 +395,17 @@ public class LineNumberReader extends BufferedReader
*/
public long skip (long count) throws IOException
{
- if (count <= 0)
+ if (count < 0)
+ throw new IllegalArgumentException("skip() value is negative");
+ if (count == 0)
return 0;
int skipped;
-
+ char[] buf = new char[1];
+
for (skipped = 0; skipped < count; skipped++)
{
- int ch = read();
+ int ch = read(buf, 0, 1);
if (ch < 0)
break;
diff --git a/libjava/java/io/ObjectInputStream.java b/libjava/java/io/ObjectInputStream.java
index 974b12df0c2..c2ddbe077c6 100644
--- a/libjava/java/io/ObjectInputStream.java
+++ b/libjava/java/io/ObjectInputStream.java
@@ -73,7 +73,7 @@ public class ObjectInputStream extends InputStream
*
* @see #readStreamHeader()
*/
- public ObjectInputStream (InputStream in)
+ public ObjectInputStream(InputStream in)
throws IOException, StreamCorruptedException
{
if (Configuration.DEBUG)
@@ -96,13 +96,14 @@ public class ObjectInputStream extends InputStream
this.blockDataPosition = 0;
this.blockDataBytes = 0;
this.blockData = new byte[BUFFER_SIZE];
- this.blockDataInput = new DataInputStream (this);
- this.realInputStream = new DataInputStream (in);
+ this.blockDataInput = new DataInputStream(this);
+ this.realInputStream = new DataInputStream(in);
this.nextOID = baseWireHandle;
- this.objectLookupTable = new Hashtable ();
- this.validators = new Vector ();
- setBlockDataMode (true);
- readStreamHeader ();
+ this.objectLookupTable = new Hashtable();
+ this.validators = new Vector();
+ this.classLookupTable = new Hashtable();
+ setBlockDataMode(true);
+ readStreamHeader();
}
@@ -121,10 +122,10 @@ public class ObjectInputStream extends InputStream
* @exception IOException Exception from underlying
* <code>InputStream</code>.
*/
- public final Object readObject () throws ClassNotFoundException, IOException
+ public final Object readObject() throws ClassNotFoundException, IOException
{
if (this.useSubclassMethod)
- return readObjectOverride ();
+ return readObjectOverride();
boolean was_deserializing;
@@ -132,12 +133,12 @@ public class ObjectInputStream extends InputStream
was_deserializing = this.isDeserializing;
boolean is_consumed = false;
- boolean old_mode = setBlockDataMode (false);
+ boolean old_mode = setBlockDataMode(false);
this.isDeserializing = true;
- byte marker = this.realInputStream.readByte ();
- dumpElement ("MARKER: 0x" + Integer.toHexString(marker) + " ");
+ byte marker = this.realInputStream.readByte();
+ dumpElement("MARKER: 0x" + Integer.toHexString(marker) + " ");
try
{
@@ -154,43 +155,43 @@ public class ObjectInputStream extends InputStream
case TC_BLOCKDATALONG:
{
if (marker == TC_BLOCKDATALONG)
- dumpElementln ("BLOCKDATALONG");
+ dumpElementln("BLOCKDATALONG");
else
- dumpElementln ("BLOCKDATA");
- readNextBlock (marker);
- throw new StreamCorruptedException ("Unexpected blockData");
+ dumpElementln("BLOCKDATA");
+ readNextBlock(marker);
+ throw new StreamCorruptedException("Unexpected blockData");
}
case TC_NULL:
{
- dumpElementln ("NULL");
+ dumpElementln("NULL");
ret_val = null;
break;
}
case TC_REFERENCE:
{
- dumpElement ("REFERENCE ");
- Integer oid = new Integer (this.realInputStream.readInt ());
- dumpElementln (Integer.toHexString(oid.intValue()));
+ dumpElement("REFERENCE ");
+ Integer oid = new Integer(this.realInputStream.readInt());
+ dumpElementln(Integer.toHexString(oid.intValue()));
ret_val = ((ObjectIdentityWrapper)
- this.objectLookupTable.get (oid)).object;
+ this.objectLookupTable.get(oid)).object;
break;
}
case TC_CLASS:
{
- dumpElementln ("CLASS");
- ObjectStreamClass osc = (ObjectStreamClass)readObject ();
- Class clazz = osc.forClass ();
- assignNewHandle (clazz);
+ dumpElementln("CLASS");
+ ObjectStreamClass osc = (ObjectStreamClass)readObject();
+ Class clazz = osc.forClass();
+ assignNewHandle(clazz);
ret_val = clazz;
break;
}
case TC_PROXYCLASSDESC:
{
- dumpElementln ("PROXYCLASS");
+ dumpElementln("PROXYCLASS");
int n_intf = this.realInputStream.readInt();
String[] intfs = new String[n_intf];
for (int i = 0; i < n_intf; i++)
@@ -199,41 +200,41 @@ public class ObjectInputStream extends InputStream
System.out.println(intfs[i]);
}
- boolean oldmode = setBlockDataMode (true);
+ boolean oldmode = setBlockDataMode(true);
Class cl = resolveProxyClass(intfs);
setBlockDataMode(oldmode);
ObjectStreamClass osc = lookupClass(cl);
- assignNewHandle (osc);
+ assignNewHandle(osc);
if (!is_consumed)
{
- byte b = this.realInputStream.readByte ();
+ byte b = this.realInputStream.readByte();
if (b != TC_ENDBLOCKDATA)
- throw new IOException ("Data annotated to class was not consumed." + b);
+ throw new IOException("Data annotated to class was not consumed." + b);
}
else
is_consumed = false;
- ObjectStreamClass superosc = (ObjectStreamClass)readObject ();
- osc.setSuperclass (superosc);
+ ObjectStreamClass superosc = (ObjectStreamClass)readObject();
+ osc.setSuperclass(superosc);
ret_val = osc;
break;
}
case TC_CLASSDESC:
{
- ObjectStreamClass osc = readClassDescriptor ();
+ ObjectStreamClass osc = readClassDescriptor();
if (!is_consumed)
{
- byte b = this.realInputStream.readByte ();
+ byte b = this.realInputStream.readByte();
if (b != TC_ENDBLOCKDATA)
- throw new IOException ("Data annotated to class was not consumed." + b);
+ throw new IOException("Data annotated to class was not consumed." + b);
}
else
is_consumed = false;
- osc.setSuperclass ((ObjectStreamClass)readObject ());
+ osc.setSuperclass ((ObjectStreamClass)readObject());
ret_val = osc;
break;
}
@@ -241,105 +242,107 @@ public class ObjectInputStream extends InputStream
case TC_STRING:
case TC_LONGSTRING:
{
- dumpElement ("STRING=");
- String s = this.realInputStream.readUTF ();
- dumpElementln (s);
- ret_val = processResolution (s, assignNewHandle (s));
+ dumpElement("STRING=");
+ String s = this.realInputStream.readUTF();
+ dumpElementln(s);
+ ret_val = processResolution(s, assignNewHandle(s));
break;
}
case TC_ARRAY:
{
- dumpElementln ("ARRAY");
- ObjectStreamClass osc = (ObjectStreamClass)readObject ();
- Class componentType = osc.forClass ().getComponentType ();
- dumpElement ("ARRAY LENGTH=");
- int length = this.realInputStream.readInt ();
+ dumpElementln("ARRAY");
+ ObjectStreamClass osc = (ObjectStreamClass)readObject();
+ Class componentType = osc.forClass().getComponentType();
+ dumpElement("ARRAY LENGTH=");
+ int length = this.realInputStream.readInt();
dumpElementln (length + "; COMPONENT TYPE=" + componentType);
- Object array = Array.newInstance (componentType, length);
- int handle = assignNewHandle (array);
- readArrayElements (array, componentType);
- for (int i=0, len=Array.getLength(array); i < len; i++)
- dumpElementln (" ELEMENT[" + i + "]=" + Array.get(array, i));
- ret_val = processResolution (array, handle);
+ Object array = Array.newInstance(componentType, length);
+ int handle = assignNewHandle(array);
+ readArrayElements(array, componentType);
+ for (int i = 0, len = Array.getLength(array); i < len; i++)
+ dumpElementln(" ELEMENT[" + i + "]=" + Array.get(array, i));
+ ret_val = processResolution(array, handle);
break;
}
case TC_OBJECT:
{
- dumpElementln ("OBJECT");
- ObjectStreamClass osc = (ObjectStreamClass)readObject ();
- Class clazz = osc.forClass ();
+ dumpElementln("OBJECT");
+ ObjectStreamClass osc = (ObjectStreamClass)readObject();
+ Class clazz = osc.forClass();
- if (!Serializable.class.isAssignableFrom (clazz))
- throw new NotSerializableException (clazz + " is not Serializable, and thus cannot be deserialized.");
+ if (!Serializable.class.isAssignableFrom(clazz))
+ throw new NotSerializableException
+ (clazz + " is not Serializable, and thus cannot be deserialized.");
- if (Externalizable.class.isAssignableFrom (clazz))
+ if (Externalizable.class.isAssignableFrom(clazz))
{
Externalizable obj = null;
try
{
- obj = (Externalizable)clazz.newInstance ();
+ obj = (Externalizable)clazz.newInstance();
}
catch (InstantiationException e)
{
- throw new ClassNotFoundException ("Instance of " + clazz
- + " could not be created");
+ throw new ClassNotFoundException
+ ("Instance of " + clazz + " could not be created");
}
catch (IllegalAccessException e)
{
- throw new ClassNotFoundException ("Instance of " + clazz
- + " could not be created because class or zero-argument constructor is not accessible");
+ throw new ClassNotFoundException
+ ("Instance of " + clazz + " could not be created because class or "
+ + "zero-argument constructor is not accessible");
}
catch (NoSuchMethodError e)
{
- throw new ClassNotFoundException ("Instance of " + clazz
- + " could not be created because zero-argument constructor is not defined");
+ throw new ClassNotFoundException
+ ("Instance of " + clazz
+ + " could not be created because zero-argument constructor is not defined");
}
- int handle = assignNewHandle (obj);
+ int handle = assignNewHandle(obj);
- boolean read_from_blocks = ((osc.getFlags () & SC_BLOCK_DATA) != 0);
+ boolean read_from_blocks = ((osc.getFlags() & SC_BLOCK_DATA) != 0);
boolean oldmode = this.readDataFromBlock;
if (read_from_blocks)
- setBlockDataMode (true);
+ setBlockDataMode(true);
- obj.readExternal (this);
+ obj.readExternal(this);
if (read_from_blocks)
- setBlockDataMode (oldmode);
+ setBlockDataMode(oldmode);
- ret_val = processResolution (obj, handle);
+ ret_val = processResolution(obj, handle);
break;
} // end if (Externalizable.class.isAssignableFrom (clazz))
// find the first non-serializable, non-abstract
// class in clazz's inheritance hierarchy
- Class first_nonserial = clazz.getSuperclass ();
- while (Serializable.class.isAssignableFrom (first_nonserial)
- || Modifier.isAbstract (first_nonserial.getModifiers ()))
- first_nonserial = first_nonserial.getSuperclass ();
+ Class first_nonserial = clazz.getSuperclass();
+ while (Serializable.class.isAssignableFrom(first_nonserial)
+ || Modifier.isAbstract(first_nonserial.getModifiers()))
+ first_nonserial = first_nonserial.getSuperclass();
Object obj = null;
- obj = newObject (clazz, first_nonserial);
+ obj = newObject(clazz, first_nonserial);
if (obj == null)
- throw new ClassNotFoundException ("Instance of " + clazz +
- " could not be created");
+ throw new ClassNotFoundException
+ ("Instance of " + clazz + " could not be created");
- int handle = assignNewHandle (obj);
+ int handle = assignNewHandle(obj);
this.currentObject = obj;
ObjectStreamClass[] hierarchy =
inputGetObjectStreamClasses(clazz);
- for (int i=0; i < hierarchy.length; i++)
+ for (int i = 0; i < hierarchy.length; i++)
{
this.currentObjectStreamClass = hierarchy[i];
- dumpElementln ("Reading fields of "
- + this.currentObjectStreamClass.getName ());
+ dumpElementln("Reading fields of " + this.currentObjectStreamClass.getName ());
// XXX: should initialize fields in classes in the hierarchy
// that aren't in the stream
@@ -349,118 +352,157 @@ public class ObjectInputStream extends InputStream
if (this.currentObjectStreamClass.hasReadMethod())
{
fieldsAlreadyRead = false;
- boolean oldmode = setBlockDataMode (true);
- callReadMethod (obj, this.currentObjectStreamClass);
- setBlockDataMode (oldmode);
- dumpElement ("ENDBLOCKDATA? ");
+ boolean oldmode = setBlockDataMode(true);
+ callReadMethod(obj, this.currentObjectStreamClass);
+ setBlockDataMode(oldmode);
+ dumpElement("ENDBLOCKDATA? ");
try
{
// FIXME: XXX: This try block is to catch EOF which is
// thrown for some objects. That indicates a bug in the logic.
- if (this.realInputStream.readByte () != TC_ENDBLOCKDATA)
- throw new IOException ("No end of block data seen for class with readObject (ObjectInputStream) method.");
- dumpElementln ("yes");
+ if (this.realInputStream.readByte() != TC_ENDBLOCKDATA)
+ throw new IOException
+ ("No end of block data seen for class with readObject (ObjectInputStream) method.");
+ dumpElementln("yes");
}
catch (EOFException e)
{
- dumpElementln ("no, got EOFException");
+ dumpElementln("no, got EOFException");
}
catch (IOException e)
{
- dumpElementln ("no, got IOException");
+ dumpElementln("no, got IOException");
}
}
else
{
- readFields (obj, currentObjectStreamClass);
+ readFields(obj, currentObjectStreamClass);
}
}
this.currentObject = null;
this.currentObjectStreamClass = null;
- ret_val = processResolution (obj, handle);
+ ret_val = processResolution(obj, handle);
break;
}
case TC_RESET:
- dumpElementln ("RESET");
- clearHandles ();
- ret_val = readObject ();
+ dumpElementln("RESET");
+ clearHandles();
+ ret_val = readObject();
break;
case TC_EXCEPTION:
{
- dumpElement ("EXCEPTION=");
- Exception e = (Exception)readObject ();
- dumpElementln (e.toString());
- clearHandles ();
- throw new WriteAbortedException ("Exception thrown during writing of stream", e);
+ dumpElement("EXCEPTION=");
+ Exception e = (Exception)readObject();
+ dumpElementln(e.toString());
+ clearHandles();
+ throw new WriteAbortedException("Exception thrown during writing of stream", e);
}
default:
- throw new IOException ("Unknown marker on stream: " + marker);
+ throw new IOException("Unknown marker on stream: " + marker);
}
}
finally
{
- setBlockDataMode (old_mode);
+ setBlockDataMode(old_mode);
this.isDeserializing = was_deserializing;
if (! was_deserializing)
{
- if (validators.size () > 0)
- invokeValidators ();
+ if (validators.size() > 0)
+ invokeValidators();
}
}
return ret_val;
}
- protected ObjectStreamClass readClassDescriptor ()
+ /**
+ * This method reads a class descriptor from the real input stream
+ * and use these data to create a new instance of ObjectStreamClass.
+ * Fields are sorted and ordered for the real read which occurs for
+ * each instance of the described class. Be aware that if you call that
+ * method you must ensure that the stream is synchronized, in the other
+ * case it may be completely desynchronized.
+ *
+ * @return A new instance of ObjectStreamClass containing the freshly
+ * created descriptor.
+ * @throws ClassNotFoundException if the required class to build the
+ * descriptor has not been found in the system.
+ * @throws IOException An input/output error occured.
+ * @throws InvalidClassException If there was a compatibility problem
+ * between the class present in the system and the serialized class.
+ */
+ protected ObjectStreamClass readClassDescriptor()
throws ClassNotFoundException, IOException
{
- dumpElement ("CLASSDESC NAME=");
- String name = this.realInputStream.readUTF ();
- dumpElement (name + "; UID=");
+ dumpElement("CLASSDESC NAME=");
+ String name = this.realInputStream.readUTF();
+ dumpElement(name + "; UID=");
long uid = this.realInputStream.readLong ();
- dumpElement (Long.toHexString(uid) + "; FLAGS=");
+ dumpElement(Long.toHexString(uid) + "; FLAGS=");
byte flags = this.realInputStream.readByte ();
- dumpElement (Integer.toHexString(flags) + "; FIELD COUNT=");
- short field_count = this.realInputStream.readShort ();
- dumpElementln (Short.toString(field_count));
+ dumpElement(Integer.toHexString(flags) + "; FIELD COUNT=");
+ short field_count = this.realInputStream.readShort();
+ dumpElementln(Short.toString(field_count));
ObjectStreamField[] fields = new ObjectStreamField[field_count];
- ObjectStreamClass osc = new ObjectStreamClass (name, uid,
- flags, fields);
- assignNewHandle (osc);
+ ObjectStreamClass osc = new ObjectStreamClass(name, uid,
+ flags, fields);
+ assignNewHandle(osc);
- for (int i=0; i < field_count; i++)
+ for (int i = 0; i < field_count; i++)
{
- dumpElement (" TYPE CODE=");
- char type_code = (char)this.realInputStream.readByte ();
- dumpElement (type_code + "; FIELD NAME=");
- String field_name = this.realInputStream.readUTF ();
- dumpElementln (field_name);
+ dumpElement(" TYPE CODE=");
+ char type_code = (char)this.realInputStream.readByte();
+ dumpElement(type_code + "; FIELD NAME=");
+ String field_name = this.realInputStream.readUTF();
+ dumpElementln(field_name);
String class_name;
+ // If the type code is an array or an object we must
+ // decode a String here. In the other case we convert
+ // the type code and pass it to ObjectStreamField.
+ // Type codes are decoded by gnu.java.lang.reflect.TypeSignature.
if (type_code == 'L' || type_code == '[')
- class_name = (String)readObject ();
+ class_name = (String)readObject();
else
- class_name = String.valueOf (type_code);
+ class_name = String.valueOf(type_code);
- // There're many cases you can't get java.lang.Class from
- // typename if your context class loader can't load it,
- // then use typename to construct the field
fields[i] =
- new ObjectStreamField (field_name, class_name);
+ new ObjectStreamField(field_name, class_name, currentLoader());
}
+ /* Now that fields have been read we may resolve the class
+ * (and read annotation if needed). */
Class clazz = resolveClass(osc);
- boolean oldmode = setBlockDataMode (true);
- osc.setClass (clazz, lookupClass(clazz.getSuperclass()));
+
+ for (int i = 0; i < field_count; i++)
+ {
+ Field f;
+
+ try
+ {
+ f = clazz.getDeclaredField(fields[i].getName());
+ if (f != null && !f.getType().equals(fields[i].getType()))
+ throw new InvalidClassException
+ ("invalid field type for " + fields[i].getName() + " in class "
+ + name + " (requested was \"" + fields[i].getType()
+ + " and found \"" + f.getType() + "\")");
+ }
+ catch (NoSuchFieldException _)
+ {
+ }
+ }
+
+ boolean oldmode = setBlockDataMode(true);
+ osc.setClass(clazz, lookupClass(clazz.getSuperclass()));
classLookupTable.put(clazz, osc);
- setBlockDataMode (oldmode);
-
+ setBlockDataMode(oldmode);
+
return osc;
}
@@ -483,17 +525,20 @@ public class ObjectInputStream extends InputStream
* @exception IOException Exception from underlying
* <code>OutputStream</code>.
*/
- public void defaultReadObject ()
+ public void defaultReadObject()
throws ClassNotFoundException, IOException, NotActiveException
{
if (this.currentObject == null || this.currentObjectStreamClass == null)
- throw new NotActiveException ("defaultReadObject called by non-active class and/or object");
+ throw new NotActiveException("defaultReadObject called by non-active"
+ + " class and/or object");
if (fieldsAlreadyRead)
- throw new NotActiveException ("defaultReadObject called but fields already read from stream (by defaultReadObject or readFields)");
+ throw new NotActiveException("defaultReadObject called but fields "
+ + "already read from stream (by "
+ + "defaultReadObject or readFields)");
boolean oldmode = setBlockDataMode(false);
- readFields (this.currentObject, this.currentObjectStreamClass);
+ readFields(this.currentObject, this.currentObjectStreamClass);
setBlockDataMode(oldmode);
fieldsAlreadyRead = true;
@@ -518,18 +563,20 @@ public class ObjectInputStream extends InputStream
* validator outside of the <code>readObject</code> method of the
* object currently being deserialized
*/
- public void registerValidation (ObjectInputValidation validator,
- int priority)
+ public void registerValidation(ObjectInputValidation validator,
+ int priority)
throws InvalidObjectException, NotActiveException
{
if (this.currentObject == null || this.currentObjectStreamClass == null)
- throw new NotActiveException ("registerValidation called by non-active class and/or object");
+ throw new NotActiveException("registerValidation called by non-active "
+ + "class and/or object");
if (validator == null)
- throw new InvalidObjectException ("attempt to add a null ObjectInputValidation object");
+ throw new InvalidObjectException("attempt to add a null "
+ + "ObjectInputValidation object");
- this.validators.addElement (new ValidatorAndPriority (validator,
- priority));
+ this.validators.addElement(new ValidatorAndPriority (validator,
+ priority));
}
@@ -549,15 +596,23 @@ public class ObjectInputStream extends InputStream
*
* @see java.io.ObjectOutputStream#annotateClass (java.lang.Class)
*/
- protected Class resolveClass (ObjectStreamClass osc)
+ protected Class resolveClass(ObjectStreamClass osc)
throws ClassNotFoundException, IOException
{
return Class.forName(osc.getName(), true, currentLoader());
}
+ /**
+ * This method invokes the method currentClassLoader for the
+ * current security manager (or build an empty one if it is not
+ * present).
+ *
+ * @return The most recent non-system ClassLoader on the execution stack.
+ * @see java.lang.SecurityManager#currentClassLoader()
+ */
private ClassLoader currentLoader()
{
- SecurityManager sm = System.getSecurityManager ();
+ SecurityManager sm = System.getSecurityManager();
if (sm == null)
sm = new SecurityManager () {};
@@ -575,13 +630,13 @@ public class ObjectInputStream extends InputStream
* @return A valid instance of ObjectStreamClass corresponding
* to the specified class.
*/
- private ObjectStreamClass lookupClass (Class clazz)
+ private ObjectStreamClass lookupClass(Class clazz)
{
ObjectStreamClass oclazz;
- oclazz = (ObjectStreamClass) classLookupTable.get(clazz);
+ oclazz = (ObjectStreamClass)classLookupTable.get(clazz);
if (oclazz == null)
- return ObjectStreamClass.lookup (clazz);
+ return ObjectStreamClass.lookup(clazz);
else
return oclazz;
}
@@ -590,17 +645,17 @@ public class ObjectInputStream extends InputStream
* Reconstruct class hierarchy the same way
* {@link java.io.ObjectStreamClass.getObjectStreamClasses(java.lang.Class)} does
* but using lookupClass instead of ObjectStreamClass.lookup. This
- * dup is necessary localize the lookup table. Hopefully some future rewritings will
- * be able to prevent this.
+ * dup is necessary localize the lookup table. Hopefully some future
+ * rewritings will be able to prevent this.
*
* @param clazz This is the class for which we want the hierarchy.
*
* @return An array of valid {@link java.io.ObjectStreamClass} instances which
* represent the class hierarchy for clazz.
*/
- private ObjectStreamClass[] inputGetObjectStreamClasses (Class clazz)
+ private ObjectStreamClass[] inputGetObjectStreamClasses(Class clazz)
{
- ObjectStreamClass osc = lookupClass (clazz);
+ ObjectStreamClass osc = lookupClass(clazz);
ObjectStreamClass[] ret_val;
@@ -639,36 +694,40 @@ public class ObjectInputStream extends InputStream
*
* @see #enableResolveObject(boolean)
*/
- protected Object resolveObject (Object obj) throws IOException
+ protected Object resolveObject(Object obj) throws IOException
{
return obj;
}
- protected Class resolveProxyClass (String[] intfs)
+ protected Class resolveProxyClass(String[] intfs)
throws IOException, ClassNotFoundException
{
- SecurityManager sm = System.getSecurityManager ();
+ SecurityManager sm = System.getSecurityManager();
if (sm == null)
- sm = new SecurityManager () {};
+ sm = new SecurityManager() {};
- ClassLoader cl = currentClassLoader (sm);
+ ClassLoader cl = currentClassLoader(sm);
Class[] clss = new Class[intfs.length];
- if(cl == null){
- for (int i = 0; i < intfs.length; i++)
- clss[i] = Class.forName(intfs[i]);
- cl = ClassLoader.getSystemClassLoader();
- }
+ if(cl == null)
+ {
+ for (int i = 0; i < intfs.length; i++)
+ clss[i] = Class.forName(intfs[i]);
+ cl = ClassLoader.getSystemClassLoader();
+ }
else
for (int i = 0; i < intfs.length; i++)
clss[i] = cl.loadClass(intfs[i]);
- try {
- return Proxy.getProxyClass(cl, clss);
- } catch (IllegalArgumentException e) {
- throw new ClassNotFoundException(null, e);
- }
+ try
+ {
+ return Proxy.getProxyClass(cl, clss);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new ClassNotFoundException(null, e);
+ }
}
/**
@@ -684,9 +743,9 @@ public class ObjectInputStream extends InputStream
{
if (enable)
{
- SecurityManager sm = System.getSecurityManager ();
+ SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkPermission (new SerializablePermission ("enableSubstitution"));
+ sm.checkPermission(new SerializablePermission("enableSubstitution"));
}
boolean old_val = this.resolveEnabled;
@@ -703,31 +762,31 @@ public class ObjectInputStream extends InputStream
* @exception StreamCorruptedException An invalid stream magic
* number or stream version was read from the stream.
*/
- protected void readStreamHeader ()
+ protected void readStreamHeader()
throws IOException, StreamCorruptedException
{
- dumpElement ("STREAM MAGIC ");
- if (this.realInputStream.readShort () != STREAM_MAGIC)
- throw new StreamCorruptedException ("Invalid stream magic number");
+ dumpElement("STREAM MAGIC ");
+ if (this.realInputStream.readShort() != STREAM_MAGIC)
+ throw new StreamCorruptedException("Invalid stream magic number");
- dumpElementln ("STREAM VERSION ");
- if (this.realInputStream.readShort () != STREAM_VERSION)
- throw new StreamCorruptedException ("Invalid stream version number");
+ dumpElementln("STREAM VERSION ");
+ if (this.realInputStream.readShort() != STREAM_VERSION)
+ throw new StreamCorruptedException("Invalid stream version number");
}
- public int read () throws IOException
+ public int read() throws IOException
{
if (this.readDataFromBlock)
{
if (this.blockDataPosition >= this.blockDataBytes)
- readNextBlock ();
+ readNextBlock();
return (this.blockData[this.blockDataPosition++] & 0xff);
}
else
- return this.realInputStream.read ();
+ return this.realInputStream.read();
}
- public int read (byte[] data, int offset, int length) throws IOException
+ public int read(byte[] data, int offset, int length) throws IOException
{
if (this.readDataFromBlock)
{
@@ -736,25 +795,25 @@ public class ObjectInputStream extends InputStream
int remain = this.blockDataBytes - this.blockDataPosition;
if (remain != 0)
{
- System.arraycopy (this.blockData, this.blockDataPosition,
- data, offset, remain);
+ System.arraycopy(this.blockData, this.blockDataPosition,
+ data, offset, remain);
offset += remain;
length -= remain;
}
readNextBlock ();
}
- System.arraycopy (this.blockData, this.blockDataPosition,
- data, offset, length);
+ System.arraycopy(this.blockData, this.blockDataPosition,
+ data, offset, length);
this.blockDataPosition += length;
return length;
}
else
- return this.realInputStream.read (data, offset, length);
+ return this.realInputStream.read(data, offset, length);
}
- public int available () throws IOException
+ public int available() throws IOException
{
if (this.readDataFromBlock)
{
@@ -764,92 +823,182 @@ public class ObjectInputStream extends InputStream
return this.blockDataBytes - this.blockDataPosition;
}
else
- return this.realInputStream.available ();
+ return this.realInputStream.available();
}
- public void close () throws IOException
+ public void close() throws IOException
{
- this.realInputStream.close ();
+ this.realInputStream.close();
}
- public boolean readBoolean () throws IOException
+ public boolean readBoolean() throws IOException
{
- return this.dataInputStream.readBoolean ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 1)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode (true);
+ boolean value = this.dataInputStream.readBoolean ();
+ if (switchmode)
+ setBlockDataMode (oldmode);
+ return value;
}
- public byte readByte () throws IOException
+ public byte readByte() throws IOException
{
- return this.dataInputStream.readByte ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 1)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode(true);
+ byte value = this.dataInputStream.readByte();
+ if (switchmode)
+ setBlockDataMode(oldmode);
+ return value;
}
- public int readUnsignedByte () throws IOException
+ public int readUnsignedByte() throws IOException
{
- return this.dataInputStream.readUnsignedByte ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 1)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode(true);
+ int value = this.dataInputStream.readUnsignedByte();
+ if (switchmode)
+ setBlockDataMode(oldmode);
+ return value;
}
- public short readShort () throws IOException
+ public short readShort() throws IOException
{
- return this.dataInputStream.readShort ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 2)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode(true);
+ short value = this.dataInputStream.readShort();
+ if (switchmode)
+ setBlockDataMode(oldmode);
+ return value;
}
- public int readUnsignedShort () throws IOException
+ public int readUnsignedShort() throws IOException
{
- return this.dataInputStream.readUnsignedShort ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 2)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode(true);
+ int value = this.dataInputStream.readUnsignedShort();
+ if (switchmode)
+ setBlockDataMode(oldmode);
+ return value;
}
- public char readChar () throws IOException
+ public char readChar() throws IOException
{
- return this.dataInputStream.readChar ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 2)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode(true);
+ char value = this.dataInputStream.readChar();
+ if (switchmode)
+ setBlockDataMode(oldmode);
+ return value;
}
- public int readInt () throws IOException
+ public int readInt() throws IOException
{
- return this.dataInputStream.readInt ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 4)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode(true);
+ int value = this.dataInputStream.readInt();
+ if (switchmode)
+ setBlockDataMode(oldmode);
+ return value;
}
- public long readLong () throws IOException
+ public long readLong() throws IOException
{
- return this.dataInputStream.readLong ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 8)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode(true);
+ long value = this.dataInputStream.readLong();
+ if (switchmode)
+ setBlockDataMode(oldmode);
+ return value;
}
- public float readFloat () throws IOException
+ public float readFloat() throws IOException
{
- return this.dataInputStream.readFloat ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 4)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode(true);
+ float value = this.dataInputStream.readFloat();
+ if (switchmode)
+ setBlockDataMode(oldmode);
+ return value;
}
- public double readDouble () throws IOException
+ public double readDouble() throws IOException
{
- return this.dataInputStream.readDouble ();
+ boolean switchmode = true;
+ boolean oldmode = this.readDataFromBlock;
+ if (!oldmode || this.blockDataBytes - this.blockDataPosition >= 8)
+ switchmode = false;
+ if (switchmode)
+ oldmode = setBlockDataMode(true);
+ double value = this.dataInputStream.readDouble();
+ if (switchmode)
+ setBlockDataMode(oldmode);
+ return value;
}
- public void readFully (byte data[]) throws IOException
+ public void readFully(byte data[]) throws IOException
{
- this.dataInputStream.readFully (data);
+ this.dataInputStream.readFully(data);
}
- public void readFully (byte data[], int offset, int size)
+ public void readFully(byte data[], int offset, int size)
throws IOException
{
- this.dataInputStream.readFully (data, offset, size);
+ this.dataInputStream.readFully(data, offset, size);
}
- public int skipBytes (int len) throws IOException
+ public int skipBytes(int len) throws IOException
{
- return this.dataInputStream.skipBytes (len);
+ return this.dataInputStream.skipBytes(len);
}
/**
* @deprecated
* @see java.io.DataInputStream#readLine ()
*/
- public String readLine () throws IOException
+ public String readLine() throws IOException
{
- return this.dataInputStream.readLine ();
+ return this.dataInputStream.readLine();
}
- public String readUTF () throws IOException
+ public String readUTF() throws IOException
{
- return this.dataInputStream.readUTF ();
+ return this.dataInputStream.readUTF();
}
/**
@@ -860,47 +1009,64 @@ public class ObjectInputStream extends InputStream
*/
public static abstract class GetField
{
- public abstract ObjectStreamClass getObjectStreamClass ();
+ public abstract ObjectStreamClass getObjectStreamClass();
- public abstract boolean defaulted (String name)
+ public abstract boolean defaulted(String name)
throws IOException, IllegalArgumentException;
- public abstract boolean get (String name, boolean defvalue)
+ public abstract boolean get(String name, boolean defvalue)
throws IOException, IllegalArgumentException;
- public abstract char get (String name, char defvalue)
+ public abstract char get(String name, char defvalue)
throws IOException, IllegalArgumentException;
- public abstract byte get (String name, byte defvalue)
+ public abstract byte get(String name, byte defvalue)
throws IOException, IllegalArgumentException;
- public abstract short get (String name, short defvalue)
+ public abstract short get(String name, short defvalue)
throws IOException, IllegalArgumentException;
- public abstract int get (String name, int defvalue)
+ public abstract int get(String name, int defvalue)
throws IOException, IllegalArgumentException;
- public abstract long get (String name, long defvalue)
+ public abstract long get(String name, long defvalue)
throws IOException, IllegalArgumentException;
- public abstract float get (String name, float defvalue)
+ public abstract float get(String name, float defvalue)
throws IOException, IllegalArgumentException;
- public abstract double get (String name, double defvalue)
+ public abstract double get(String name, double defvalue)
throws IOException, IllegalArgumentException;
- public abstract Object get (String name, Object defvalue)
+ public abstract Object get(String name, Object defvalue)
throws IOException, IllegalArgumentException;
}
- public GetField readFields ()
+ /**
+ * This method should be called by a method called 'readObject' in the
+ * deserializing class (if present). It cannot (and should not)be called
+ * outside of it. Its goal is to read all fields in the real input stream
+ * and keep them accessible through the {@link #GetField} class. Calling
+ * this method will not alterate the deserializing object.
+ *
+ * @return A valid freshly created 'GetField' instance to get access to
+ * the deserialized stream.
+ * @throws IOException An input/output exception occured.
+ * @throws ClassNotFoundException
+ * @throws NotActiveException
+ */
+ public GetField readFields()
throws IOException, ClassNotFoundException, NotActiveException
{
if (this.currentObject == null || this.currentObjectStreamClass == null)
- throw new NotActiveException ("readFields called by non-active class and/or object");
+ throw new NotActiveException("readFields called by non-active class and/or object");
+
+ if (prereadFields != null)
+ return prereadFields;
if (fieldsAlreadyRead)
- throw new NotActiveException ("readFields called but fields already read from stream (by defaultReadObject or readFields)");
+ throw new NotActiveException("readFields called but fields already read from"
+ + " stream (by defaultReadObject or readFields)");
final ObjectStreamClass clazz = this.currentObjectStreamClass;
final byte[] prim_field_data = new byte[clazz.primFieldSize];
@@ -909,84 +1075,108 @@ public class ObjectInputStream extends InputStream
// Apparently Block data is not used with GetField as per
// empirical evidence against JDK 1.2. Also see Mauve test
// java.io.ObjectInputOutput.Test.GetPutField.
- boolean oldmode = setBlockDataMode (false);
- readFully (prim_field_data);
+ boolean oldmode = setBlockDataMode(false);
+ readFully(prim_field_data);
for (int i = 0; i < objs.length; ++ i)
- objs[i] = readObject ();
- setBlockDataMode (oldmode);
+ objs[i] = readObject();
+ setBlockDataMode(oldmode);
- return new GetField ()
+ prereadFields = new GetField()
{
- public ObjectStreamClass getObjectStreamClass ()
+ public ObjectStreamClass getObjectStreamClass()
{
return clazz;
}
- public boolean defaulted (String name)
+ public boolean defaulted(String name)
throws IOException, IllegalArgumentException
{
- return clazz.getField (name) == null;
+ ObjectStreamField f = clazz.getField(name);
+
+ /* First if we have a serialized field use the descriptor */
+ if (f != null)
+ {
+ /* It is in serialPersistentFields but setClass tells us
+ * it should not be set. This value is defaulted.
+ */
+ if (f.isPersistent() && !f.isToSet())
+ return true;
+
+ return false;
+ }
+
+ /* This is not a serialized field. There should be
+ * a default value only if the field really exists.
+ */
+ try
+ {
+ return (clazz.forClass().getDeclaredField (name) != null);
+ }
+ catch (NoSuchFieldException e)
+ {
+ throw new IllegalArgumentException(e.getMessage());
+ }
}
- public boolean get (String name, boolean defvalue)
+ public boolean get(String name, boolean defvalue)
throws IOException, IllegalArgumentException
{
- ObjectStreamField field = getField (name, Boolean.TYPE);
+ ObjectStreamField field = getField(name, Boolean.TYPE);
if (field == null)
return defvalue;
- return prim_field_data[field.getOffset ()] == 0 ? false : true;
+ return prim_field_data[field.getOffset()] == 0 ? false : true;
}
- public char get (String name, char defvalue)
+ public char get(String name, char defvalue)
throws IOException, IllegalArgumentException
{
- ObjectStreamField field = getField (name, Character.TYPE);
+ ObjectStreamField field = getField(name, Character.TYPE);
if (field == null)
return defvalue;
- int off = field.getOffset ();
+ int off = field.getOffset();
return (char)(((prim_field_data[off++] & 0xFF) << 8)
| (prim_field_data[off] & 0xFF));
}
- public byte get (String name, byte defvalue)
+ public byte get(String name, byte defvalue)
throws IOException, IllegalArgumentException
{
- ObjectStreamField field = getField (name, Byte.TYPE);
+ ObjectStreamField field = getField(name, Byte.TYPE);
if (field == null)
return defvalue;
- return prim_field_data[field.getOffset ()];
+ return prim_field_data[field.getOffset()];
}
- public short get (String name, short defvalue)
+ public short get(String name, short defvalue)
throws IOException, IllegalArgumentException
{
- ObjectStreamField field = getField (name, Short.TYPE);
+ ObjectStreamField field = getField(name, Short.TYPE);
if (field == null)
return defvalue;
- int off = field.getOffset ();
+ int off = field.getOffset();
return (short)(((prim_field_data[off++] & 0xFF) << 8)
| (prim_field_data[off] & 0xFF));
}
- public int get (String name, int defvalue)
+ public int get(String name, int defvalue)
throws IOException, IllegalArgumentException
{
- ObjectStreamField field = getField (name, Integer.TYPE);
+ ObjectStreamField field = getField(name, Integer.TYPE);
if (field == null)
return defvalue;
- int off = field.getOffset ();
+ int off = field.getOffset();
return ((prim_field_data[off++] & 0xFF) << 24)
| ((prim_field_data[off++] & 0xFF) << 16)
@@ -994,15 +1184,15 @@ public class ObjectInputStream extends InputStream
| (prim_field_data[off] & 0xFF);
}
- public long get (String name, long defvalue)
+ public long get(String name, long defvalue)
throws IOException, IllegalArgumentException
{
- ObjectStreamField field = getField (name, Long.TYPE);
+ ObjectStreamField field = getField(name, Long.TYPE);
if (field == null)
return defvalue;
- int off = field.getOffset ();
+ int off = field.getOffset();
return (long)(((prim_field_data[off++] & 0xFF) << 56)
| ((prim_field_data[off++] & 0xFF) << 48)
@@ -1014,31 +1204,31 @@ public class ObjectInputStream extends InputStream
| (prim_field_data[off] & 0xFF));
}
- public float get (String name, float defvalue)
+ public float get(String name, float defvalue)
throws IOException, IllegalArgumentException
{
- ObjectStreamField field = getField (name, Float.TYPE);
+ ObjectStreamField field = getField(name, Float.TYPE);
if (field == null)
return defvalue;
- int off = field.getOffset ();
+ int off = field.getOffset();
- return Float.intBitsToFloat (((prim_field_data[off++] & 0xFF) << 24)
- | ((prim_field_data[off++] & 0xFF) << 16)
- | ((prim_field_data[off++] & 0xFF) << 8)
- | (prim_field_data[off] & 0xFF));
+ return Float.intBitsToFloat(((prim_field_data[off++] & 0xFF) << 24)
+ | ((prim_field_data[off++] & 0xFF) << 16)
+ | ((prim_field_data[off++] & 0xFF) << 8)
+ | (prim_field_data[off] & 0xFF));
}
- public double get (String name, double defvalue)
+ public double get(String name, double defvalue)
throws IOException, IllegalArgumentException
{
- ObjectStreamField field = getField (name, Double.TYPE);
+ ObjectStreamField field = getField(name, Double.TYPE);
if (field == null)
return defvalue;
- int off = field.getOffset ();
+ int off = field.getOffset();
return Double.longBitsToDouble
( (long) (((prim_field_data[off++] & 0xFF) << 56)
@@ -1051,40 +1241,92 @@ public class ObjectInputStream extends InputStream
| (prim_field_data[off] & 0xFF)));
}
- public Object get (String name, Object defvalue)
+ public Object get(String name, Object defvalue)
throws IOException, IllegalArgumentException
{
ObjectStreamField field =
- getField (name, defvalue == null ? null : defvalue.getClass ());
+ getField(name, defvalue == null ? null : defvalue.getClass ());
if (field == null)
return defvalue;
- return objs[field.getOffset ()];
+ return objs[field.getOffset()];
}
- private ObjectStreamField getField (String name, Class type)
+ private ObjectStreamField getField(String name, Class type)
throws IllegalArgumentException
{
- ObjectStreamField field = clazz.getField (name);
-
- if (field == null)
- return null;
-
- Class field_type = field.getType ();
-
- if (type == field_type ||
- (type == null && ! field_type.isPrimitive ()))
- return field;
+ ObjectStreamField field = clazz.getField(name);
+ boolean illegal = false;
- throw new IllegalArgumentException ("Field requested is of type "
- + field_type.getName ()
- + ", but requested type was "
- + (type == null ?
- "Object" : type.getName ()));
+ try
+ {
+ try
+ {
+ Class field_type = field.getType();
+
+ if (type == field_type ||
+ (type == null && !field_type.isPrimitive()))
+ {
+ /* See defaulted */
+ return field;
+ }
+
+ illegal = true;
+ throw new IllegalArgumentException
+ ("Field requested is of type "
+ + field_type.getName()
+ + ", but requested type was "
+ + (type == null ? "Object" : type.getName()));
+ }
+ catch (NullPointerException _)
+ {
+ /* Here we catch NullPointerException, because it may
+ only come from the call 'field.getType()'. If field
+ is null, we have to return null and classpath ethic
+ say we must try to avoid 'if (xxx == null)'.
+ */
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw e;
+ }
+
+ return null;
+ }
+ finally
+ {
+ /* If this is an unassigned field we should return
+ * the default value.
+ */
+ if (!illegal && field != null && !field.isToSet() && field.isPersistent())
+ return null;
+
+ /* We do not want to modify transient fields. They should
+ * be left to 0.
+ */
+ try
+ {
+ Field f = clazz.forClass().getDeclaredField(name);
+ if (Modifier.isTransient(f.getModifiers()))
+ throw new IllegalArgumentException
+ ("no such field (non transient) " + name);
+ if (field == null && f.getType() != type)
+ throw new IllegalArgumentException
+ ("Invalid requested type for field " + name);
+ }
+ catch (NoSuchFieldException e)
+ {
+ if (field == null)
+ throw new IllegalArgumentException(e.getMessage());
+ }
+
+ }
}
};
+ fieldsAlreadyRead = true;
+ return prereadFields;
}
/**
@@ -1098,12 +1340,12 @@ public class ObjectInputStream extends InputStream
*
* @see #readObjectOverride()
*/
- protected ObjectInputStream ()
+ protected ObjectInputStream()
throws IOException, SecurityException
{
- SecurityManager sec_man = System.getSecurityManager ();
+ SecurityManager sec_man = System.getSecurityManager();
if (sec_man != null)
- sec_man.checkPermission (SUBCLASS_IMPLEMENTATION_PERMISSION);
+ sec_man.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
this.useSubclassMethod = true;
}
@@ -1116,10 +1358,10 @@ public class ObjectInputStream extends InputStream
*
* @see #ObjectInputStream()
*/
- protected Object readObjectOverride ()
+ protected Object readObjectOverride()
throws ClassNotFoundException, IOException, OptionalDataException
{
- throw new IOException ("Subclass of ObjectInputStream must implement readObjectOverride");
+ throw new IOException("Subclass of ObjectInputStream must implement readObjectOverride");
}
/**
@@ -1128,14 +1370,14 @@ public class ObjectInputStream extends InputStream
* @param obj The object for which we want a new handle.
* @return A valid handle for the specified object.
*/
- private int assignNewHandle (Object obj)
+ private int assignNewHandle(Object obj)
{
- this.objectLookupTable.put (new Integer (this.nextOID),
- new ObjectIdentityWrapper (obj));
+ this.objectLookupTable.put(new Integer(this.nextOID),
+ new ObjectIdentityWrapper(obj));
return this.nextOID++;
}
- private Object processResolution (Object obj, int handle)
+ private Object processResolution(Object obj, int handle)
throws IOException
{
if (obj instanceof Serializable)
@@ -1145,7 +1387,7 @@ public class ObjectInputStream extends InputStream
{
Class classArgs[] = {};
m = getMethod(obj.getClass(), "readResolve", classArgs);
- obj = m.invoke (obj, new Object[] {});
+ obj = m.invoke(obj, new Object[] {});
}
catch (NoSuchMethodException ignore)
{
@@ -1159,42 +1401,42 @@ public class ObjectInputStream extends InputStream
}
if (this.resolveEnabled)
- obj = resolveObject (obj);
+ obj = resolveObject(obj);
- this.objectLookupTable.put (new Integer (handle),
- new ObjectIdentityWrapper (obj));
+ this.objectLookupTable.put(new Integer(handle),
+ new ObjectIdentityWrapper(obj));
return obj;
}
- private void clearHandles ()
+ private void clearHandles()
{
- this.objectLookupTable.clear ();
+ this.objectLookupTable.clear();
this.nextOID = baseWireHandle;
}
- private void readNextBlock () throws IOException
+ private void readNextBlock() throws IOException
{
- readNextBlock (this.realInputStream.readByte ());
+ readNextBlock(this.realInputStream.readByte());
}
- private void readNextBlock (byte marker) throws IOException
+ private void readNextBlock(byte marker) throws IOException
{
if (marker == TC_BLOCKDATA)
{
- dumpElement ("BLOCK DATA SIZE=");
- this.blockDataBytes = this.realInputStream.readUnsignedByte ();
+ dumpElement("BLOCK DATA SIZE=");
+ this.blockDataBytes = this.realInputStream.readUnsignedByte();
dumpElementln (Integer.toString(this.blockDataBytes));
}
else if (marker == TC_BLOCKDATALONG)
{
- dumpElement ("BLOCK DATA LONG SIZE=");
- this.blockDataBytes = this.realInputStream.readInt ();
+ dumpElement("BLOCK DATA LONG SIZE=");
+ this.blockDataBytes = this.realInputStream.readInt();
dumpElementln (Integer.toString(this.blockDataBytes));
}
else
{
- throw new EOFException ("Attempt to read primitive data, but no data block is active.");
+ throw new EOFException("Attempt to read primitive data, but no data block is active.");
}
if (this.blockData.length < this.blockDataBytes)
@@ -1207,62 +1449,62 @@ public class ObjectInputStream extends InputStream
private void readArrayElements (Object array, Class clazz)
throws ClassNotFoundException, IOException
{
- if (clazz.isPrimitive ())
+ if (clazz.isPrimitive())
{
if (clazz == Boolean.TYPE)
{
boolean[] cast_array = (boolean[])array;
for (int i=0; i < cast_array.length; i++)
- cast_array[i] = this.realInputStream.readBoolean ();
+ cast_array[i] = this.realInputStream.readBoolean();
return;
}
if (clazz == Byte.TYPE)
{
byte[] cast_array = (byte[])array;
for (int i=0; i < cast_array.length; i++)
- cast_array[i] = this.realInputStream.readByte ();
+ cast_array[i] = this.realInputStream.readByte();
return;
}
if (clazz == Character.TYPE)
{
char[] cast_array = (char[])array;
for (int i=0; i < cast_array.length; i++)
- cast_array[i] = this.realInputStream.readChar ();
+ cast_array[i] = this.realInputStream.readChar();
return;
}
if (clazz == Double.TYPE)
{
double[] cast_array = (double[])array;
for (int i=0; i < cast_array.length; i++)
- cast_array[i] = this.realInputStream.readDouble ();
+ cast_array[i] = this.realInputStream.readDouble();
return;
}
if (clazz == Float.TYPE)
{
float[] cast_array = (float[])array;
for (int i=0; i < cast_array.length; i++)
- cast_array[i] = this.realInputStream.readFloat ();
+ cast_array[i] = this.realInputStream.readFloat();
return;
}
if (clazz == Integer.TYPE)
{
int[] cast_array = (int[])array;
for (int i=0; i < cast_array.length; i++)
- cast_array[i] = this.realInputStream.readInt ();
+ cast_array[i] = this.realInputStream.readInt();
return;
}
if (clazz == Long.TYPE)
{
long[] cast_array = (long[])array;
for (int i=0; i < cast_array.length; i++)
- cast_array[i] = this.realInputStream.readLong ();
+ cast_array[i] = this.realInputStream.readLong();
return;
}
if (clazz == Short.TYPE)
{
short[] cast_array = (short[])array;
for (int i=0; i < cast_array.length; i++)
- cast_array[i] = this.realInputStream.readShort ();
+ cast_array[i] = this.realInputStream.readShort();
return;
}
}
@@ -1270,7 +1512,7 @@ public class ObjectInputStream extends InputStream
{
Object[] cast_array = (Object[])array;
for (int i=0; i < cast_array.length; i++)
- cast_array[i] = readObject ();
+ cast_array[i] = readObject();
}
}
@@ -1300,7 +1542,7 @@ public class ObjectInputStream extends InputStream
else
{
stream_field = stream_fields[stream_idx];
- type = stream_field.getType ();
+ type = stream_field.getType();
}
if (real_idx == real_fields.length)
@@ -1308,8 +1550,8 @@ public class ObjectInputStream extends InputStream
else
{
real_field = real_fields[real_idx];
- type = real_field.getType ();
- field_name = real_field.getName ();
+ type = real_field.getType();
+ field_name = real_field.getName();
}
if (set_value && !default_initialize)
@@ -1334,87 +1576,96 @@ public class ObjectInputStream extends InputStream
}
}
+ if (stream_field.getOffset() < 0)
+ {
+ default_initialize = true;
+ set_value = false;
+ }
+
+ if (!stream_field.isToSet())
+ set_value = false;
+
try
{
if (type == Boolean.TYPE)
{
boolean value =
- default_initialize ? false : this.realInputStream.readBoolean ();
+ default_initialize ? false : this.realInputStream.readBoolean();
if (!default_initialize && set_value)
- dumpElementln (" " + field_name + ": " + value);
+ dumpElementln(" " + field_name + ": " + value);
if (set_value)
- setBooleanField (obj, stream_osc.forClass (), field_name, value);
+ setBooleanField(obj, stream_osc.forClass(), field_name, value);
}
else if (type == Byte.TYPE)
{
byte value =
- default_initialize ? 0 : this.realInputStream.readByte ();
+ default_initialize ? 0 : this.realInputStream.readByte();
if (!default_initialize && set_value)
- dumpElementln (" " + field_name + ": " + value);
+ dumpElementln(" " + field_name + ": " + value);
if (set_value)
- setByteField (obj, stream_osc.forClass (), field_name, value);
+ setByteField(obj, stream_osc.forClass(), field_name, value);
}
else if (type == Character.TYPE)
{
char value =
- default_initialize ? (char)0 : this.realInputStream.readChar ();
+ default_initialize ? (char)0 : this.realInputStream.readChar();
if (!default_initialize && set_value)
- dumpElementln (" " + field_name + ": " + value);
+ dumpElementln(" " + field_name + ": " + value);
if (set_value)
- setCharField (obj, stream_osc.forClass (), field_name, value);
+ setCharField(obj, stream_osc.forClass(), field_name, value);
}
else if (type == Double.TYPE)
{
double value =
- default_initialize ? 0 : this.realInputStream.readDouble ();
+ default_initialize ? 0 : this.realInputStream.readDouble();
if (!default_initialize && set_value)
- dumpElementln (" " + field_name + ": " + value);
+ dumpElementln(" " + field_name + ": " + value);
if (set_value)
- setDoubleField (obj, stream_osc.forClass (), field_name, value);
+ setDoubleField(obj, stream_osc.forClass(), field_name, value);
}
else if (type == Float.TYPE)
{
float value =
- default_initialize ? 0 : this.realInputStream.readFloat ();
+ default_initialize ? 0 : this.realInputStream.readFloat();
if (!default_initialize && set_value)
- dumpElementln (" " + field_name + ": " + value);
+ dumpElementln(" " + field_name + ": " + value);
if (set_value)
- setFloatField (obj, stream_osc.forClass (), field_name, value);
+ setFloatField(obj, stream_osc.forClass(), field_name, value);
}
else if (type == Integer.TYPE)
{
int value =
- default_initialize ? 0 : this.realInputStream.readInt ();
+ default_initialize ? 0 : this.realInputStream.readInt();
if (!default_initialize && set_value)
- dumpElementln (" " + field_name + ": " + value);
+ dumpElementln(" " + field_name + ": " + value);
if (set_value)
- setIntField (obj, stream_osc.forClass (), field_name, value);
+ setIntField(obj, stream_osc.forClass(), field_name, value);
}
else if (type == Long.TYPE)
{
long value =
- default_initialize ? 0 : this.realInputStream.readLong ();
+ default_initialize ? 0 : this.realInputStream.readLong();
if (!default_initialize && set_value)
- dumpElementln (" " + field_name + ": " + value);
+ dumpElementln(" " + field_name + ": " + value);
if (set_value)
- setLongField (obj, stream_osc.forClass (), field_name, value);
+ setLongField(obj, stream_osc.forClass(), field_name, value);
}
else if (type == Short.TYPE)
{
short value =
- default_initialize ? (short)0 : this.realInputStream.readShort ();
+ default_initialize ? (short)0 : this.realInputStream.readShort();
if (!default_initialize && set_value)
- dumpElementln (" " + field_name + ": " + value);
+ dumpElementln(" " + field_name + ": " + value);
if (set_value)
- setShortField (obj, stream_osc.forClass (), field_name, value);
+ setShortField(obj, stream_osc.forClass(), field_name, value);
}
else
{
Object value =
- default_initialize ? null : readObject ();
+ default_initialize ? null : readObject();
if (set_value)
- setObjectField (obj, stream_osc.forClass (), field_name,
- real_field.getTypeString (), value);
+ setObjectField(obj, stream_osc.forClass(), field_name,
+ real_field.getTypeString(), value);
}
}
catch (NoSuchFieldError e)
@@ -1455,20 +1706,20 @@ public class ObjectInputStream extends InputStream
// runs all registered ObjectInputValidations in prioritized order
// on OBJ
- private void invokeValidators () throws InvalidObjectException
+ private void invokeValidators() throws InvalidObjectException
{
- Object[] validators = new Object[this.validators.size ()];
+ Object[] validators = new Object[this.validators.size()];
this.validators.copyInto (validators);
Arrays.sort (validators);
try
{
for (int i=0; i < validators.length; i++)
- ((ObjectInputValidation)validators[i]).validateObject ();
+ ((ObjectInputValidation)validators[i]).validateObject();
}
finally
{
- this.validators.removeAllElements ();
+ this.validators.removeAllElements();
}
}
@@ -1485,10 +1736,24 @@ public class ObjectInputStream extends InputStream
return ClassLoader.getSystemClassLoader ();
}
- private static Field getField (Class klass, String name)
+ /**
+ * This method tries to access a precise field called in the
+ * specified class. Before accessing the field, it tries to
+ * gain control on this field. If the field is either declared as
+ * not persistent or transient then it returns null
+ * immediately.
+ *
+ * @param klass Class to get the field from.
+ * @param name Name of the field to access.
+ * @return Field instance representing the requested field.
+ * @throws NoSuchFieldException if the field does not exist.
+ */
+ private Field getField(Class klass, String name)
throws java.lang.NoSuchFieldException
{
final Field f = klass.getDeclaredField(name);
+ ObjectStreamField sf = lookupClass(klass).getField(name);
+
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
@@ -1497,6 +1762,14 @@ public class ObjectInputStream extends InputStream
return null;
}
});
+
+ /* We do not want to modify transient fields. They should
+ * be left to 0.
+ * N.B.: Not valid if the field is in serialPersistentFields.
+ */
+ if (Modifier.isTransient(f.getModifiers()) && !sf.isPersistent())
+ return null;
+
return f;
}
@@ -1523,7 +1796,7 @@ public class ObjectInputStream extends InputStream
Class classArgs[] = {ObjectInputStream.class};
Method m = getMethod (klass, "readObject", classArgs);
Object args[] = {this};
- m.invoke (obj, args);
+ m.invoke(obj, args);
}
catch (NoSuchMethodException nsme)
{
@@ -1538,14 +1811,17 @@ public class ObjectInputStream extends InputStream
if (exception instanceof IOException)
throw (IOException) exception;
- throw new IOException ("Exception thrown from readObject() on " +
+ throw new IOException("Exception thrown from readObject() on " +
klass + ": " + exception.getClass().getName());
}
catch (Exception x)
{
- throw new IOException ("Failure invoking readObject() on " +
+ throw new IOException("Failure invoking readObject() on " +
klass + ": " + x.getClass().getName());
}
+
+ // Invalidate fields which has been read through readFields.
+ prereadFields = null;
}
private native Object allocateObject (Class clazz)
@@ -1564,13 +1840,13 @@ public class ObjectInputStream extends InputStream
* @throws InvalidClassException if the specified field has not the required type.
* @throws IOException if there is no field of that name in the specified class.
*/
- private void setBooleanField (Object obj, Class klass, String field_name,
+ private void setBooleanField(Object obj, Class klass, String field_name,
boolean val) throws IOException, InvalidClassException
{
try
{
- Field f = getField (klass, field_name);
- f.setBoolean (obj, val);
+ Field f = getField(klass, field_name);
+ f.setBoolean(obj, val);
}
catch (IllegalArgumentException _)
{
@@ -1592,13 +1868,13 @@ public class ObjectInputStream extends InputStream
* @throws InvalidClassException if the specified field has not the required type.
* @throws IOException if there is no field of that name in the specified class.
*/
- private void setByteField (Object obj, Class klass, String field_name,
+ private void setByteField(Object obj, Class klass, String field_name,
byte val) throws IOException, InvalidClassException
{
try
{
- Field f = getField (klass, field_name);
- f.setByte (obj, val);
+ Field f = getField(klass, field_name);
+ f.setByte(obj, val);
}
catch (IllegalArgumentException _)
{
@@ -1620,13 +1896,13 @@ public class ObjectInputStream extends InputStream
* @throws InvalidClassException if the specified field has not the required type.
* @throws IOException if there is no field of that name in the specified class.
*/
- private void setCharField (Object obj, Class klass, String field_name,
+ private void setCharField(Object obj, Class klass, String field_name,
char val) throws IOException, InvalidClassException
{
try
{
- Field f = getField (klass, field_name);
- f.setChar (obj, val);
+ Field f = getField(klass, field_name);
+ f.setChar(obj, val);
}
catch (IllegalArgumentException _)
{
@@ -1648,13 +1924,13 @@ public class ObjectInputStream extends InputStream
* @throws InvalidClassException if the specified field has not the required type.
* @throws IOException if there is no field of that name in the specified class.
*/
- private void setDoubleField (Object obj, Class klass, String field_name,
+ private void setDoubleField(Object obj, Class klass, String field_name,
double val) throws IOException, InvalidClassException
{
try
{
- Field f = getField (klass, field_name);
- f.setDouble (obj, val);
+ Field f = getField(klass, field_name);
+ f.setDouble(obj, val);
}
catch (IllegalArgumentException _)
{
@@ -1676,13 +1952,13 @@ public class ObjectInputStream extends InputStream
* @throws InvalidClassException if the specified field has not the required type.
* @throws IOException if there is no field of that name in the specified class.
*/
- private void setFloatField (Object obj, Class klass, String field_name,
+ private void setFloatField(Object obj, Class klass, String field_name,
float val) throws IOException, InvalidClassException
{
try
{
- Field f = getField (klass, field_name);
- f.setFloat (obj, val);
+ Field f = getField(klass, field_name);
+ f.setFloat(obj, val);
}
catch (IllegalArgumentException _)
{
@@ -1704,13 +1980,13 @@ public class ObjectInputStream extends InputStream
* @throws InvalidClassException if the specified field has not the required type.
* @throws IOException if there is no field of that name in the specified class.
*/
- private void setIntField (Object obj, Class klass, String field_name,
+ private void setIntField(Object obj, Class klass, String field_name,
int val) throws IOException, InvalidClassException
{
try
{
- Field f = getField (klass, field_name);
- f.setInt (obj, val);
+ Field f = getField(klass, field_name);
+ f.setInt(obj, val);
}
catch (IllegalArgumentException _)
{
@@ -1732,13 +2008,13 @@ public class ObjectInputStream extends InputStream
* @throws InvalidClassException if the specified field has not the required type.
* @throws IOException if there is no field of that name in the specified class.
*/
- private void setLongField (Object obj, Class klass, String field_name,
+ private void setLongField(Object obj, Class klass, String field_name,
long val) throws IOException, InvalidClassException
{
try
{
- Field f = getField (klass, field_name);
- f.setLong (obj, val);
+ Field f = getField(klass, field_name);
+ f.setLong(obj, val);
}
catch (IllegalArgumentException _)
{
@@ -1760,13 +2036,13 @@ public class ObjectInputStream extends InputStream
* @throws InvalidClassException if the specified field has not the required type.
* @throws IOException if there is no field of that name in the specified class.
*/
- private void setShortField (Object obj, Class klass, String field_name,
+ private void setShortField(Object obj, Class klass, String field_name,
short val) throws IOException, InvalidClassException
{
try
{
- Field f = getField (klass, field_name);
- f.setShort (obj, val);
+ Field f = getField(klass, field_name);
+ f.setShort(obj, val);
}
catch (IllegalArgumentException _)
{
@@ -1788,25 +2064,26 @@ public class ObjectInputStream extends InputStream
* @throws InvalidClassException if the specified field has not the required type.
* @throws IOException if there is no field of that name in the specified class.
*/
- private void setObjectField (Object obj, Class klass, String field_name,
+ private void setObjectField(Object obj, Class klass, String field_name,
String type_code, Object val) throws IOException, InvalidClassException
{
try
{
- Field f = getField (klass, field_name);
+ Field f = getField(klass, field_name);
ObjectStreamField of = new ObjectStreamField(field_name, f.getType());
if (of.getTypeString() == null ||
!of.getTypeString().equals(type_code))
throw new InvalidClassException("incompatible field type for " + klass.getName() + "." + field_name);
- f.set (obj, val);
+ f.set(obj, val);
}
catch (InvalidClassException e)
{
throw e;
}
catch (Exception _)
- {}
+ {
+ }
}
private static final int BUFFER_SIZE = 1024;
@@ -1829,6 +2106,7 @@ public class ObjectInputStream extends InputStream
private boolean fieldsAlreadyRead;
private Vector validators;
private Hashtable classLookupTable;
+ private GetField prereadFields;
private static boolean dump;
diff --git a/libjava/java/io/ObjectOutputStream.java b/libjava/java/io/ObjectOutputStream.java
index f79ac3e4d8a..8f991f0baa1 100644
--- a/libjava/java/io/ObjectOutputStream.java
+++ b/libjava/java/io/ObjectOutputStream.java
@@ -132,18 +132,18 @@ public class ObjectOutputStream extends OutputStream
*/
public ObjectOutputStream (OutputStream out) throws IOException
{
- realOutput = new DataOutputStream (out);
+ realOutput = new DataOutputStream(out);
blockData = new byte[ BUFFER_SIZE ];
blockDataCount = 0;
- blockDataOutput = new DataOutputStream (this);
- setBlockDataMode (true);
+ blockDataOutput = new DataOutputStream(this);
+ setBlockDataMode(true);
replacementEnabled = false;
isSerializing = false;
nextOID = baseWireHandle;
- OIDLookupTable = new Hashtable ();
+ OIDLookupTable = new Hashtable();
protocolVersion = defaultProtocolVersion;
useSubclassMethod = false;
- writeStreamHeader ();
+ writeStreamHeader();
}
/**
@@ -165,16 +165,16 @@ public class ObjectOutputStream extends OutputStream
* @exception IOException Exception from underlying
* <code>OutputStream</code>.
*/
- public final void writeObject (Object obj) throws IOException
+ public final void writeObject(Object obj) throws IOException
{
if (useSubclassMethod)
{
- writeObjectOverride (obj);
+ writeObjectOverride(obj);
return;
}
boolean was_serializing = isSerializing;
- boolean old_mode = setBlockDataMode (false);
+ boolean old_mode = setBlockDataMode(false);
try
{
isSerializing = true;
@@ -185,49 +185,49 @@ public class ObjectOutputStream extends OutputStream
{
if (obj == null)
{
- realOutput.writeByte (TC_NULL);
+ realOutput.writeByte(TC_NULL);
break;
}
- Integer handle = findHandle (obj);
+ Integer handle = findHandle(obj);
if (handle != null)
{
- realOutput.writeByte (TC_REFERENCE);
- realOutput.writeInt (handle.intValue ());
+ realOutput.writeByte(TC_REFERENCE);
+ realOutput.writeInt(handle.intValue());
break;
}
if (obj instanceof Class)
{
Class cl = (Class)obj;
- ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject (cl);
- assignNewHandle (obj);
- realOutput.writeByte (TC_CLASS);
+ ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject(cl);
+ assignNewHandle(obj);
+ realOutput.writeByte(TC_CLASS);
if (!osc.isProxyClass)
{
writeObject (osc);
}
else
{
- realOutput.writeByte (TC_PROXYCLASSDESC);
+ realOutput.writeByte(TC_PROXYCLASSDESC);
Class[] intfs = cl.getInterfaces();
realOutput.writeInt(intfs.length);
for (int i = 0; i < intfs.length; i++)
realOutput.writeUTF(intfs[i].getName());
- boolean oldmode = setBlockDataMode (true);
+ boolean oldmode = setBlockDataMode(true);
annotateProxyClass(cl);
- setBlockDataMode (oldmode);
+ setBlockDataMode(oldmode);
realOutput.writeByte(TC_ENDBLOCKDATA);
- writeObject (osc.getSuper());
+ writeObject(osc.getSuper());
}
break;
}
if (obj instanceof ObjectStreamClass)
{
- writeClassDescriptor ((ObjectStreamClass) obj);
+ writeClassDescriptor((ObjectStreamClass) obj);
break;
}
@@ -235,7 +235,7 @@ public class ObjectOutputStream extends OutputStream
&& ! replaceDone)
{
replacedObject = obj;
-
+
if (obj instanceof Serializable)
{
Method m = null;
@@ -247,7 +247,7 @@ public class ObjectOutputStream extends OutputStream
// m can't be null by definition since an
// exception would have been thrown so a check
// for null is not needed.
- obj = m.invoke (obj, new Object[] {});
+ obj = m.invoke(obj, new Object[] {});
}
catch (NoSuchMethodException ignore)
{
@@ -259,55 +259,55 @@ public class ObjectOutputStream extends OutputStream
{
}
}
-
+
if (replacementEnabled)
- obj = replaceObject (obj);
-
+ obj = replaceObject(obj);
+
replaceDone = true;
continue;
}
if (obj instanceof String)
{
- realOutput.writeByte (TC_STRING);
- assignNewHandle (obj);
- realOutput.writeUTF ((String)obj);
+ realOutput.writeByte(TC_STRING);
+ assignNewHandle(obj);
+ realOutput.writeUTF((String)obj);
break;
}
- Class clazz = obj.getClass ();
- ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject (clazz);
+ Class clazz = obj.getClass();
+ ObjectStreamClass osc = ObjectStreamClass.lookupForClassObject(clazz);
if (osc == null)
- throw new NotSerializableException (clazz.getName ());
-
+ throw new NotSerializableException(clazz.getName());
+
if (clazz.isArray ())
{
- realOutput.writeByte (TC_ARRAY);
- writeObject (osc);
- assignNewHandle (obj);
- writeArraySizeAndElements (obj, clazz.getComponentType ());
+ realOutput.writeByte(TC_ARRAY);
+ writeObject(osc);
+ assignNewHandle(obj);
+ writeArraySizeAndElements(obj, clazz.getComponentType());
break;
}
-
- realOutput.writeByte (TC_OBJECT);
- writeObject (osc);
+
+ realOutput.writeByte(TC_OBJECT);
+ writeObject(osc);
if (replaceDone)
- assignNewHandle (replacedObject);
+ assignNewHandle(replacedObject);
else
- assignNewHandle (obj);
+ assignNewHandle(obj);
if (obj instanceof Externalizable)
{
if (protocolVersion == PROTOCOL_VERSION_2)
- setBlockDataMode (true);
-
- ((Externalizable)obj).writeExternal (this);
-
+ setBlockDataMode(true);
+
+ ((Externalizable)obj).writeExternal(this);
+
if (protocolVersion == PROTOCOL_VERSION_2)
{
- setBlockDataMode (false);
- realOutput.writeByte (TC_ENDBLOCKDATA);
+ setBlockDataMode(false);
+ realOutput.writeByte(TC_ENDBLOCKDATA);
}
break;
@@ -317,22 +317,22 @@ public class ObjectOutputStream extends OutputStream
{
currentObject = obj;
ObjectStreamClass[] hierarchy =
- ObjectStreamClass.getObjectStreamClasses (clazz);
-
- for (int i=0; i < hierarchy.length; i++)
+ ObjectStreamClass.getObjectStreamClasses(clazz);
+
+ for (int i = 0; i < hierarchy.length; i++)
{
currentObjectStreamClass = hierarchy[i];
-
+
fieldsAlreadyWritten = false;
- if (currentObjectStreamClass.hasWriteMethod ())
+ if (currentObjectStreamClass.hasWriteMethod())
{
- setBlockDataMode (true);
- callWriteMethod (obj, currentObjectStreamClass);
- setBlockDataMode (false);
- realOutput.writeByte (TC_ENDBLOCKDATA);
+ setBlockDataMode(true);
+ callWriteMethod(obj, currentObjectStreamClass);
+ setBlockDataMode(false);
+ realOutput.writeByte(TC_ENDBLOCKDATA);
}
else
- writeFields (obj, currentObjectStreamClass);
+ writeFields(obj, currentObjectStreamClass);
}
currentObject = null;
@@ -341,7 +341,7 @@ public class ObjectOutputStream extends OutputStream
break;
}
- throw new NotSerializableException (clazz.getName ());
+ throw new NotSerializableException(clazz.getName ());
} // end pseudo-loop
}
catch (ObjectStreamException ose)
@@ -351,242 +351,247 @@ public class ObjectOutputStream extends OutputStream
}
catch (IOException e)
{
- realOutput.writeByte (TC_EXCEPTION);
- reset (true);
+ realOutput.writeByte(TC_EXCEPTION);
+ reset(true);
- setBlockDataMode (false);
+ setBlockDataMode(false);
try
{
- writeObject (e);
+ writeObject(e);
}
catch (IOException ioe)
{
- throw new StreamCorruptedException ("Exception " + ioe + " thrown while exception ("+e+") was being written to stream.");
+ throw new StreamCorruptedException
+ ("Exception " + ioe + " thrown while exception was being written to stream.");
}
reset (true);
+
}
finally
{
isSerializing = was_serializing;
- setBlockDataMode (old_mode);
+ setBlockDataMode(old_mode);
}
}
- protected void writeClassDescriptor (ObjectStreamClass osc) throws IOException
+ protected void writeClassDescriptor(ObjectStreamClass osc) throws IOException
{
- realOutput.writeByte (TC_CLASSDESC);
- realOutput.writeUTF (osc.getName ());
- realOutput.writeLong (osc.getSerialVersionUID ());
- assignNewHandle (osc);
+ realOutput.writeByte(TC_CLASSDESC);
+ realOutput.writeUTF(osc.getName());
+ realOutput.writeLong(osc.getSerialVersionUID());
+ assignNewHandle(osc);
- int flags = osc.getFlags ();
+ int flags = osc.getFlags();
if (protocolVersion == PROTOCOL_VERSION_2
- && osc.isExternalizable ())
+ && osc.isExternalizable())
flags |= SC_BLOCK_DATA;
- realOutput.writeByte (flags);
+ realOutput.writeByte(flags);
ObjectStreamField[] fields = osc.fields;
- realOutput.writeShort (fields.length);
+ realOutput.writeShort(fields.length);
ObjectStreamField field;
- for (int i=0; i < fields.length; i++)
+ for (int i = 0; i < fields.length; i++)
{
field = fields[i];
- realOutput.writeByte (field.getTypeCode ());
- realOutput.writeUTF (field.getName ());
+ realOutput.writeByte(field.getTypeCode ());
+ realOutput.writeUTF(field.getName ());
- if (! field.isPrimitive ())
- writeObject (field.getTypeString ());
+ if (! field.isPrimitive())
+ writeObject(field.getTypeString());
}
- boolean oldmode = setBlockDataMode (true);
- annotateClass (osc.forClass ());
- setBlockDataMode (oldmode);
- realOutput.writeByte (TC_ENDBLOCKDATA);
+ boolean oldmode = setBlockDataMode(true);
+ annotateClass(osc.forClass());
+ setBlockDataMode(oldmode);
+ realOutput.writeByte(TC_ENDBLOCKDATA);
- if (osc.isSerializable ())
- writeObject (osc.getSuper ());
+ if (osc.isSerializable() || osc.isExternalizable())
+ writeObject(osc.getSuper());
else
- writeObject (null);
+ writeObject(null);
}
/**
- Writes the current objects non-transient, non-static fields from
- the current class to the underlying output stream.
-
- This method is intended to be called from within a object's
- <code>private void writeObject (ObjectOutputStream)</code>
- method.
-
- @exception NotActiveException This method was called from a
- context other than from the current object's and current class's
- <code>private void writeObject (ObjectOutputStream)</code>
- method.
-
- @exception IOException Exception from underlying
- <code>OutputStream</code>.
- */
- public void defaultWriteObject ()
+ * Writes the current objects non-transient, non-static fields from
+ * the current class to the underlying output stream.
+ *
+ * This method is intended to be called from within a object's
+ * <code>private void writeObject (ObjectOutputStream)</code>
+ * method.
+ *
+ * @exception NotActiveException This method was called from a
+ * context other than from the current object's and current class's
+ * <code>private void writeObject (ObjectOutputStream)</code>
+ * method.
+ *
+ * @exception IOException Exception from underlying
+ * <code>OutputStream</code>.
+ */
+ public void defaultWriteObject()
throws IOException, NotActiveException
{
- markFieldsWritten ();
- writeFields (currentObject, currentObjectStreamClass);
+ markFieldsWritten();
+ writeFields(currentObject, currentObjectStreamClass);
}
- private void markFieldsWritten () throws IOException
+ private void markFieldsWritten() throws IOException
{
if (currentObject == null || currentObjectStreamClass == null)
- throw new NotActiveException ("defaultWriteObject called by non-active class and/or object");
+ throw new NotActiveException
+ ("defaultWriteObject called by non-active class and/or object");
if (fieldsAlreadyWritten)
- throw new IOException ("Only one of writeFields and defaultWriteObject may be called, and it may only be called once");
+ throw new IOException
+ ("Only one of putFields and defaultWriteObject may be called, and it may only be called once");
fieldsAlreadyWritten = true;
}
-
/**
- Resets stream to state equivalent to the state just after it was
- constructed.
-
- Causes all objects previously written to the stream to be
- forgotten. A notification of this reset is also written to the
- underlying stream.
-
- @exception IOException Exception from underlying
- <code>OutputStream</code> or reset called while serialization is
- in progress.
- */
- public void reset () throws IOException
+ * Resets stream to state equivalent to the state just after it was
+ * constructed.
+ *
+ * Causes all objects previously written to the stream to be
+ * forgotten. A notification of this reset is also written to the
+ * underlying stream.
+ *
+ * @exception IOException Exception from underlying
+ * <code>OutputStream</code> or reset called while serialization is
+ * in progress.
+ */
+ public void reset() throws IOException
{
- reset (false);
+ reset(false);
}
- private void reset (boolean internal) throws IOException
+ private void reset(boolean internal) throws IOException
{
if (!internal)
{
if (isSerializing)
- throw new IOException ("Reset called while serialization in progress");
+ throw new IOException("Reset called while serialization in progress");
- realOutput.writeByte (TC_RESET);
+ realOutput.writeByte(TC_RESET);
}
-
- clearHandles ();
+
+ clearHandles();
}
/**
- Informs this <code>ObjectOutputStream</code> to write data
- according to the specified protocol. There are currently two
- different protocols, specified by <code>PROTOCOL_VERSION_1</code>
- and <code>PROTOCOL_VERSION_2</code>. This implementation writes
- data using <code>PROTOCOL_VERSION_2</code> by default, as is done
- by the JDK 1.2.
-
- A non-portable method, <code>setDefaultProtocolVersion (int
- version)</code> is provided to change the default protocol
- version.
-
- For an explination of the differences beween the two protocols
- see XXX: the Java ObjectSerialization Specification.
-
- @exception IOException if <code>version</code> is not a valid
- protocol
-
- @see #setDefaultProtocolVersion(int)
- */
- public void useProtocolVersion (int version) throws IOException
+ * Informs this <code>ObjectOutputStream</code> to write data
+ * according to the specified protocol. There are currently two
+ * different protocols, specified by <code>PROTOCOL_VERSION_1</code>
+ * and <code>PROTOCOL_VERSION_2</code>. This implementation writes
+ * data using <code>PROTOCOL_VERSION_2</code> by default, as is done
+ * by the JDK 1.2.
+ *
+ * A non-portable method, <code>setDefaultProtocolVersion (int
+ * version)</code> is provided to change the default protocol
+ * version.
+ *
+ * For an explination of the differences beween the two protocols
+ * see XXX: the Java ObjectSerialization Specification.
+ *
+ * @exception IOException if <code>version</code> is not a valid
+ * protocol
+ *
+ * @see #setDefaultProtocolVersion(int)
+ */
+ public void useProtocolVersion(int version) throws IOException
{
if (version != PROTOCOL_VERSION_1 && version != PROTOCOL_VERSION_2)
- throw new IOException ("Invalid protocol version requested.");
-
+ throw new IOException("Invalid protocol version requested.");
+
protocolVersion = version;
}
/**
- <em>GNU $classpath specific</em>
-
- Changes the default stream protocol used by all
- <code>ObjectOutputStream</code>s. There are currently two
- different protocols, specified by <code>PROTOCOL_VERSION_1</code>
- and <code>PROTOCOL_VERSION_2</code>. The default default is
- <code>PROTOCOL_VERSION_1</code>.
-
- @exception IOException if <code>version</code> is not a valid
- protocol
-
- @see #useProtocolVersion(int)
- */
- public static void setDefaultProtocolVersion (int version)
+ * <em>GNU $classpath specific</em>
+ *
+ * Changes the default stream protocol used by all
+ * <code>ObjectOutputStream</code>s. There are currently two
+ * different protocols, specified by <code>PROTOCOL_VERSION_1</code>
+ * and <code>PROTOCOL_VERSION_2</code>. The default default is
+ * <code>PROTOCOL_VERSION_1</code>.
+ *
+ * @exception IOException if <code>version</code> is not a valid
+ * protocol
+ *
+ * @see #useProtocolVersion(int)
+ */
+ public static void setDefaultProtocolVersion(int version)
throws IOException
{
if (version != PROTOCOL_VERSION_1 && version != PROTOCOL_VERSION_2)
- throw new IOException ("Invalid protocol version requested.");
+ throw new IOException("Invalid protocol version requested.");
defaultProtocolVersion = version;
}
/**
- An empty hook that allows subclasses to write extra information
- about classes to the stream. This method is called the first
- time each class is seen, and after all of the standard
- information about the class has been written.
-
- @exception IOException Exception from underlying
- <code>OutputStream</code>.
-
- @see ObjectInputStream#resolveClass(java.io.ObjectStreamClass)
- */
- protected void annotateClass (Class cl) throws IOException
- {}
+ * An empty hook that allows subclasses to write extra information
+ * about classes to the stream. This method is called the first
+ * time each class is seen, and after all of the standard
+ * information about the class has been written.
+ *
+ * @exception IOException Exception from underlying
+ * <code>OutputStream</code>.
+ *
+ * @see ObjectInputStream#resolveClass(java.io.ObjectStreamClass)
+ */
+ protected void annotateClass(Class cl) throws IOException
+ {
+ }
protected void annotateProxyClass(Class cl) throws IOException
- {}
+ {
+ }
/**
- Allows subclasses to replace objects that are written to the
- stream with other objects to be written in their place. This
- method is called the first time each object is encountered
- (modulo reseting of the stream).
-
- This method must be enabled before it will be called in the
- serialization process.
-
- @exception IOException Exception from underlying
- <code>OutputStream</code>.
-
- @see #enableReplaceObject(boolean)
- */
- protected Object replaceObject (Object obj) throws IOException
+ * Allows subclasses to replace objects that are written to the
+ * stream with other objects to be written in their place. This
+ * method is called the first time each object is encountered
+ * (modulo reseting of the stream).
+ *
+ * This method must be enabled before it will be called in the
+ * serialization process.
+ *
+ * @exception IOException Exception from underlying
+ * <code>OutputStream</code>.
+ *
+ * @see #enableReplaceObject(boolean)
+ */
+ protected Object replaceObject(Object obj) throws IOException
{
return obj;
}
/**
- If <code>enable</code> is <code>true</code> and this object is
- trusted, then <code>replaceObject (Object)</code> will be called
- in subsequent calls to <code>writeObject (Object)</code>.
- Otherwise, <code>replaceObject (Object)</code> will not be called.
-
- @exception SecurityException This class is not trusted.
- */
- protected boolean enableReplaceObject (boolean enable)
+ * If <code>enable</code> is <code>true</code> and this object is
+ * trusted, then <code>replaceObject (Object)</code> will be called
+ * in subsequent calls to <code>writeObject (Object)</code>.
+ * Otherwise, <code>replaceObject (Object)</code> will not be called.
+ *
+ * @exception SecurityException This class is not trusted.
+ */
+ protected boolean enableReplaceObject(boolean enable)
throws SecurityException
{
if (enable)
{
- SecurityManager sm = System.getSecurityManager ();
+ SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkPermission (new SerializablePermission ("enableSubstitution"));
+ sm.checkPermission(new SerializablePermission("enableSubstitution"));
}
boolean old_val = replacementEnabled;
@@ -596,20 +601,18 @@ public class ObjectOutputStream extends OutputStream
/**
- Writes stream magic and stream version information to the
- underlying stream.
-
- @exception IOException Exception from underlying
- <code>OutputStream</code>.
- */
- protected void writeStreamHeader () throws IOException
+ * Writes stream magic and stream version information to the
+ * underlying stream.
+ *
+ * @exception IOException Exception from underlying
+ * <code>OutputStream</code>.
+ */
+ protected void writeStreamHeader() throws IOException
{
- realOutput.writeShort (STREAM_MAGIC);
- realOutput.writeShort (STREAM_VERSION);
+ realOutput.writeShort(STREAM_MAGIC);
+ realOutput.writeShort(STREAM_VERSION);
}
-
-
/**
* Protected constructor that allows subclasses to override
* serialization. This constructor should be called by subclasses
@@ -621,11 +624,11 @@ public class ObjectOutputStream extends OutputStream
*
* @see #writeObjectOverride(Object)
*/
- protected ObjectOutputStream () throws IOException, SecurityException
+ protected ObjectOutputStream() throws IOException, SecurityException
{
SecurityManager sec_man = System.getSecurityManager ();
if (sec_man != null)
- sec_man.checkPermission (SUBCLASS_IMPLEMENTATION_PERMISSION);
+ sec_man.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
useSubclassMethod = true;
}
@@ -642,10 +645,11 @@ public class ObjectOutputStream extends OutputStream
* @exception NotActiveException Subclass has arranged for this
* method to be called, but did not implement this method.
*/
- protected void writeObjectOverride (Object obj) throws NotActiveException,
+ protected void writeObjectOverride(Object obj) throws NotActiveException,
IOException
{
- throw new NotActiveException ("Subclass of ObjectOutputStream must implement writeObjectOverride");
+ throw new NotActiveException
+ ("Subclass of ObjectOutputStream must implement writeObjectOverride");
}
@@ -657,48 +661,48 @@ public class ObjectOutputStream extends OutputStream
if (writeDataAsBlocks)
{
if (blockDataCount == BUFFER_SIZE)
- drain ();
+ drain();
blockData[ blockDataCount++ ] = (byte)data;
}
else
- realOutput.write (data);
+ realOutput.write(data);
}
/**
* @see DataOutputStream#write(byte[])
*/
- public void write (byte[] b) throws IOException
+ public void write(byte[] b) throws IOException
{
- write (b, 0, b.length);
+ write(b, 0, b.length);
}
/**
* @see DataOutputStream#write(byte[],int,int)
*/
- public void write (byte[] b, int off, int len) throws IOException
+ public void write(byte[] b, int off, int len) throws IOException
{
if (writeDataAsBlocks)
{
if (len < 0)
- throw new IndexOutOfBoundsException ();
+ throw new IndexOutOfBoundsException();
if (blockDataCount + len < BUFFER_SIZE)
{
- System.arraycopy (b, off, blockData, blockDataCount, len);
+ System.arraycopy(b, off, blockData, blockDataCount, len);
blockDataCount += len;
}
else
{
- drain ();
- writeBlockDataHeader (len);
- realOutput.write (b, off, len);
+ drain();
+ writeBlockDataHeader(len);
+ realOutput.write(b, off, len);
}
}
else
- realOutput.write (b, off, len);
+ realOutput.write(b, off, len);
}
@@ -707,8 +711,8 @@ public class ObjectOutputStream extends OutputStream
*/
public void flush () throws IOException
{
- drain ();
- realOutput.flush ();
+ drain();
+ realOutput.flush();
}
@@ -719,14 +723,14 @@ public class ObjectOutputStream extends OutputStream
* @exception IOException Exception from underlying
* <code>OutputStream</code>.
*/
- protected void drain () throws IOException
+ protected void drain() throws IOException
{
if (blockDataCount == 0)
return;
if (writeDataAsBlocks)
- writeBlockDataHeader (blockDataCount);
- realOutput.write (blockData, 0, blockDataCount);
+ writeBlockDataHeader(blockDataCount);
+ realOutput.write(blockData, 0, blockDataCount);
blockDataCount = 0;
}
@@ -734,28 +738,28 @@ public class ObjectOutputStream extends OutputStream
/**
* @see java.io.DataOutputStream#close ()
*/
- public void close () throws IOException
+ public void close() throws IOException
{
- flush ();
- realOutput.close ();
+ flush();
+ realOutput.close();
}
/**
* @see java.io.DataOutputStream#writeBoolean (boolean)
*/
- public void writeBoolean (boolean data) throws IOException
+ public void writeBoolean(boolean data) throws IOException
{
- blockDataOutput.writeBoolean (data);
+ blockDataOutput.writeBoolean(data);
}
/**
* @see java.io.DataOutputStream#writeByte (int)
*/
- public void writeByte (int data) throws IOException
+ public void writeByte(int data) throws IOException
{
- blockDataOutput.writeByte (data);
+ blockDataOutput.writeByte(data);
}
@@ -764,79 +768,79 @@ public class ObjectOutputStream extends OutputStream
*/
public void writeShort (int data) throws IOException
{
- blockDataOutput.writeShort (data);
+ blockDataOutput.writeShort(data);
}
/**
* @see java.io.DataOutputStream#writeChar (int)
*/
- public void writeChar (int data) throws IOException
+ public void writeChar(int data) throws IOException
{
- blockDataOutput.writeChar (data);
+ blockDataOutput.writeChar(data);
}
/**
* @see java.io.DataOutputStream#writeInt (int)
*/
- public void writeInt (int data) throws IOException
+ public void writeInt(int data) throws IOException
{
- blockDataOutput.writeInt (data);
+ blockDataOutput.writeInt(data);
}
/**
* @see java.io.DataOutputStream#writeLong (long)
*/
- public void writeLong (long data) throws IOException
+ public void writeLong(long data) throws IOException
{
- blockDataOutput.writeLong (data);
+ blockDataOutput.writeLong(data);
}
/**
* @see java.io.DataOutputStream#writeFloat (float)
*/
- public void writeFloat (float data) throws IOException
+ public void writeFloat(float data) throws IOException
{
- blockDataOutput.writeFloat (data);
+ blockDataOutput.writeFloat(data);
}
/**
* @see java.io.DataOutputStream#writeDouble (double)
*/
- public void writeDouble (double data) throws IOException
+ public void writeDouble(double data) throws IOException
{
- blockDataOutput.writeDouble (data);
+ blockDataOutput.writeDouble(data);
}
/**
* @see java.io.DataOutputStream#writeBytes (java.lang.String)
*/
- public void writeBytes (String data) throws IOException
+ public void writeBytes(String data) throws IOException
{
- blockDataOutput.writeBytes (data);
+ blockDataOutput.writeBytes(data);
}
/**
* @see java.io.DataOutputStream#writeChars (java.lang.String)
*/
- public void writeChars (String data) throws IOException
+ public void writeChars(String data) throws IOException
{
- dataOutput.writeChars (data);
+ dataOutput.writeChars(data);
}
/**
* @see java.io.DataOutputStream#writeUTF (java.lang.String)
*/
- public void writeUTF (String data) throws IOException
+ public void writeUTF(String data) throws IOException
{
- dataOutput.writeUTF (data);
+ dataOutput.writeUTF(data);
}
@@ -864,7 +868,7 @@ public class ObjectOutputStream extends OutputStream
public abstract void write (ObjectOutput out) throws IOException;
}
- public PutField putFields () throws IOException
+ public PutField putFields() throws IOException
{
if (currentPutField == null)
{
@@ -1007,183 +1011,184 @@ public class ObjectOutputStream extends OutputStream
}
- public void writeFields () throws IOException
+ public void writeFields() throws IOException
{
if (currentPutField == null)
- throw new NotActiveException ("writeFields can only be called after putFields has been called");
+ throw new NotActiveException("writeFields can only be called after putFields has been called");
// putFields may be called more than once, but not writeFields.
markFieldsWritten();
- currentPutField.write (this);
+ currentPutField.write(this);
currentPutField = null;
}
// write out the block-data buffer, picking the correct header
// depending on the size of the buffer
- private void writeBlockDataHeader (int size) throws IOException
+ private void writeBlockDataHeader(int size) throws IOException
{
if (size < 256)
{
- realOutput.writeByte (TC_BLOCKDATA);
- realOutput.write (size);
+ realOutput.writeByte(TC_BLOCKDATA);
+ realOutput.write(size);
}
else
{
- realOutput.writeByte (TC_BLOCKDATALONG);
- realOutput.writeInt (size);
+ realOutput.writeByte(TC_BLOCKDATALONG);
+ realOutput.writeInt(size);
}
}
// lookup the handle for OBJ, return null if OBJ doesn't have a
// handle yet
- private Integer findHandle (Object obj)
+ private Integer findHandle(Object obj)
{
- return (Integer)OIDLookupTable.get (new ObjectIdentityWrapper (obj));
+ return (Integer)OIDLookupTable.get(new ObjectIdentityWrapper(obj));
}
// assigns the next availible handle to OBJ
- private int assignNewHandle (Object obj)
+ private int assignNewHandle(Object obj)
{
- OIDLookupTable.put (new ObjectIdentityWrapper (obj),
- new Integer (nextOID));
+ OIDLookupTable.put(new ObjectIdentityWrapper(obj),
+ new Integer(nextOID));
return nextOID++;
}
// resets mapping from objects to handles
- private void clearHandles ()
+ private void clearHandles()
{
nextOID = baseWireHandle;
- OIDLookupTable.clear ();
+ OIDLookupTable.clear();
}
// write out array size followed by each element of the array
- private void writeArraySizeAndElements (Object array, Class clazz)
+ private void writeArraySizeAndElements(Object array, Class clazz)
throws IOException
{
- int length = Array.getLength (array);
+ int length = Array.getLength(array);
- if (clazz.isPrimitive ())
+ if (clazz.isPrimitive())
{
if (clazz == Boolean.TYPE)
{
boolean[] cast_array = (boolean[])array;
realOutput.writeInt (length);
- for (int i=0; i < length; i++)
- realOutput.writeBoolean (cast_array[i]);
+ for (int i = 0; i < length; i++)
+ realOutput.writeBoolean(cast_array[i]);
return;
}
if (clazz == Byte.TYPE)
{
byte[] cast_array = (byte[])array;
- realOutput.writeInt (length);
+ realOutput.writeInt(length);
realOutput.write(cast_array, 0, length);
return;
}
if (clazz == Character.TYPE)
{
char[] cast_array = (char[])array;
- realOutput.writeInt (length);
- for (int i=0; i < length; i++)
- realOutput.writeChar (cast_array[i]);
+ realOutput.writeInt(length);
+ for (int i = 0; i < length; i++)
+ realOutput.writeChar(cast_array[i]);
return;
}
if (clazz == Double.TYPE)
{
double[] cast_array = (double[])array;
- realOutput.writeInt (length);
- for (int i=0; i < length; i++)
- realOutput.writeDouble (cast_array[i]);
+ realOutput.writeInt(length);
+ for (int i = 0; i < length; i++)
+ realOutput.writeDouble(cast_array[i]);
return;
}
if (clazz == Float.TYPE)
{
float[] cast_array = (float[])array;
- realOutput.writeInt (length);
- for (int i=0; i < length; i++)
- realOutput.writeFloat (cast_array[i]);
+ realOutput.writeInt(length);
+ for (int i = 0; i < length; i++)
+ realOutput.writeFloat(cast_array[i]);
return;
}
if (clazz == Integer.TYPE)
{
int[] cast_array = (int[])array;
- realOutput.writeInt (length);
- for (int i=0; i < length; i++)
- realOutput.writeInt (cast_array[i]);
+ realOutput.writeInt(length);
+ for (int i = 0; i < length; i++)
+ realOutput.writeInt(cast_array[i]);
return;
}
if (clazz == Long.TYPE)
{
long[] cast_array = (long[])array;
realOutput.writeInt (length);
- for (int i=0; i < length; i++)
- realOutput.writeLong (cast_array[i]);
+ for (int i = 0; i < length; i++)
+ realOutput.writeLong(cast_array[i]);
return;
}
if (clazz == Short.TYPE)
{
short[] cast_array = (short[])array;
realOutput.writeInt (length);
- for (int i=0; i < length; i++)
- realOutput.writeShort (cast_array[i]);
+ for (int i = 0; i < length; i++)
+ realOutput.writeShort(cast_array[i]);
return;
}
}
else
{
Object[] cast_array = (Object[])array;
- realOutput.writeInt (length);
- for (int i=0; i < length; i++)
- writeObject (cast_array[i]);
+ realOutput.writeInt(length);
+ for (int i = 0; i < length; i++)
+ writeObject(cast_array[i]);
}
}
// writes out FIELDS of OBJECT for the specified ObjectStreamClass.
// FIELDS are already in canonical order.
- private void writeFields (Object obj, ObjectStreamClass osc)
+ private void writeFields(Object obj, ObjectStreamClass osc)
throws IOException
{
ObjectStreamField[] fields = osc.fields;
- boolean oldmode = setBlockDataMode (false);
+ boolean oldmode = setBlockDataMode(false);
String field_name;
Class type;
- for (int i=0; i < fields.length; i++)
+
+ for (int i = 0; i < fields.length; i++)
{
- field_name = fields[i].getName ();
- type = fields[i].getType ();
+ field_name = fields[i].getName();
+ type = fields[i].getType();
if (type == Boolean.TYPE)
- realOutput.writeBoolean (getBooleanField (obj, osc.forClass(), field_name));
+ realOutput.writeBoolean(getBooleanField(obj, osc.forClass(), field_name));
else if (type == Byte.TYPE)
- realOutput.writeByte (getByteField (obj, osc.forClass(), field_name));
+ realOutput.writeByte(getByteField(obj, osc.forClass(), field_name));
else if (type == Character.TYPE)
- realOutput.writeChar (getCharField (obj, osc.forClass(), field_name));
+ realOutput.writeChar(getCharField(obj, osc.forClass(), field_name));
else if (type == Double.TYPE)
- realOutput.writeDouble (getDoubleField (obj, osc.forClass(), field_name));
+ realOutput.writeDouble(getDoubleField(obj, osc.forClass(), field_name));
else if (type == Float.TYPE)
- realOutput.writeFloat (getFloatField (obj, osc.forClass(), field_name));
+ realOutput.writeFloat(getFloatField(obj, osc.forClass(), field_name));
else if (type == Integer.TYPE)
- realOutput.writeInt (getIntField (obj, osc.forClass(), field_name));
+ realOutput.writeInt(getIntField(obj, osc.forClass(), field_name));
else if (type == Long.TYPE)
- realOutput.writeLong (getLongField (obj, osc.forClass(), field_name));
+ realOutput.writeLong(getLongField(obj, osc.forClass(), field_name));
else if (type == Short.TYPE)
- realOutput.writeShort (getShortField (obj, osc.forClass(), field_name));
+ realOutput.writeShort(getShortField(obj, osc.forClass(), field_name));
else
- writeObject (getObjectField (obj, osc.forClass(), field_name,
- fields[i].getTypeString ()));
+ writeObject(getObjectField(obj, osc.forClass(), field_name,
+ fields[i].getTypeString ()));
}
- setBlockDataMode (oldmode);
+ setBlockDataMode(oldmode);
}
// Toggles writing primitive data to block-data buffer.
- private boolean setBlockDataMode (boolean on) throws IOException
+ private boolean setBlockDataMode(boolean on) throws IOException
{
if (on == writeDataAsBlocks)
return on;
@@ -1201,16 +1206,16 @@ public class ObjectOutputStream extends OutputStream
}
- private void callWriteMethod (Object obj, ObjectStreamClass osc)
+ private void callWriteMethod(Object obj, ObjectStreamClass osc)
throws IOException
{
Class klass = osc.forClass();
try
{
Class classArgs[] = {ObjectOutputStream.class};
- Method m = getMethod (klass, "writeObject", classArgs);
+ Method m = getMethod(klass, "writeObject", classArgs);
Object args[] = {this};
- m.invoke (obj, args);
+ m.invoke(obj, args);
}
catch (NoSuchMethodException nsme)
{
@@ -1226,34 +1231,34 @@ public class ObjectOutputStream extends OutputStream
throw (IOException) exception;
IOException ioe
- = new IOException ("Exception thrown from writeObject() on " +
- klass + ": " + exception.getClass().getName());
+ = new IOException("Exception thrown from writeObject() on " +
+ klass + ": " + exception.getClass().getName());
ioe.initCause(exception);
throw ioe;
}
catch (Exception x)
{
IOException ioe
- = new IOException ("Failure invoking writeObject() on " +
- klass + ": " + x.getClass().getName());
+ = new IOException("Failure invoking writeObject() on " +
+ klass + ": " + x.getClass().getName());
ioe.initCause(x);
throw ioe;
}
}
- private boolean getBooleanField (Object obj, Class klass, String field_name)
+ private boolean getBooleanField(Object obj, Class klass, String field_name)
throws IOException
{
try
{
- Field f = getField (klass, field_name);
- boolean b = f.getBoolean (obj);
+ Field f = getField(klass, field_name);
+ boolean b = f.getBoolean(obj);
return b;
}
catch (Exception _)
{
- throw new IOException ("Unexpected Exception "+_);
- }
+ throw new IOException("Unexpected exception " + _);
+ }
}
private byte getByteField (Object obj, Class klass, String field_name)
@@ -1267,7 +1272,7 @@ public class ObjectOutputStream extends OutputStream
}
catch (Exception _)
{
- throw new IOException ("Unexpected Exception "+_);
+ throw new IOException("Unexpected exception " + _);
}
}
@@ -1282,7 +1287,7 @@ public class ObjectOutputStream extends OutputStream
}
catch (Exception _)
{
- throw new IOException ("Unexpected Exception "+_);
+ throw new IOException("Unexpected exception " + _);
}
}
@@ -1297,7 +1302,7 @@ public class ObjectOutputStream extends OutputStream
}
catch (Exception _)
{
- throw new IOException ("Unexpected Exception "+_);
+ throw new IOException("Unexpected exception " + _);
}
}
@@ -1312,8 +1317,8 @@ public class ObjectOutputStream extends OutputStream
}
catch (Exception _)
{
- throw new IOException ("Unexpected Exception "+_);
- }
+ throw new IOException("Unexpected exception " + _);
+ }
}
private int getIntField (Object obj, Class klass, String field_name)
@@ -1327,8 +1332,8 @@ public class ObjectOutputStream extends OutputStream
}
catch (Exception _)
{
- throw new IOException ("Unexpected Exception "+_);
- }
+ throw new IOException("Unexpected exception " + _);
+ }
}
private long getLongField (Object obj, Class klass, String field_name)
@@ -1342,7 +1347,7 @@ public class ObjectOutputStream extends OutputStream
}
catch (Exception _)
{
- throw new IOException ("Unexpected Exception "+_);
+ throw new IOException("Unexpected exception " + _);
}
}
@@ -1357,8 +1362,8 @@ public class ObjectOutputStream extends OutputStream
}
catch (Exception _)
{
- throw new IOException ("Unexpected Exception "+_);
- }
+ throw new IOException("Unexpected exception " + _);
+ }
}
private Object getObjectField (Object obj, Class klass, String field_name,
@@ -1371,9 +1376,9 @@ public class ObjectOutputStream extends OutputStream
// FIXME: We should check the type_code here
return o;
}
- catch (Exception _)
+ catch (Exception e)
{
- throw new IOException ("Unexpected Exception "+_);
+ throw new IOException ();
}
}
@@ -1433,7 +1438,7 @@ public class ObjectOutputStream extends OutputStream
{
if (Configuration.INIT_LOAD_LIBRARY)
{
- System.loadLibrary ("javaio");
+ System.loadLibrary("javaio");
}
}
}
diff --git a/libjava/java/io/ObjectStreamClass.java b/libjava/java/io/ObjectStreamClass.java
index 0be9a7e5053..5bd0e686625 100644
--- a/libjava/java/io/ObjectStreamClass.java
+++ b/libjava/java/io/ObjectStreamClass.java
@@ -2,39 +2,39 @@
about serialized objects.
Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
-This file is part of GNU Classpath.
+ This file is part of GNU Classpath.
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
package java.io;
@@ -61,23 +61,23 @@ import gnu.java.security.provider.Gnu;
public class ObjectStreamClass implements Serializable
{
/**
- Returns the <code>ObjectStreamClass</code> for <code>cl</code>.
- If <code>cl</code> is null, or is not <code>Serializable</code>,
- null is returned. <code>ObjectStreamClass</code>'s are memorized;
- later calls to this method with the same class will return the
- same <code>ObjectStreamClass</code> object and no recalculation
- will be done.
-
- @see java.io.Serializable
- */
- public static ObjectStreamClass lookup (Class cl)
+ * Returns the <code>ObjectStreamClass</code> for <code>cl</code>.
+ * If <code>cl</code> is null, or is not <code>Serializable</code>,
+ * null is returned. <code>ObjectStreamClass</code>'s are memorized;
+ * later calls to this method with the same class will return the
+ * same <code>ObjectStreamClass</code> object and no recalculation
+ * will be done.
+ *
+ * @see java.io.Serializable
+ */
+ public static ObjectStreamClass lookup(Class cl)
{
if (cl == null)
return null;
- if (! (Serializable.class).isAssignableFrom (cl))
+ if (! (Serializable.class).isAssignableFrom(cl))
return null;
- return lookupForClassObject (cl);
+ return lookupForClassObject(cl);
}
/**
@@ -85,57 +85,57 @@ public class ObjectStreamClass implements Serializable
* we have a java.lang.Class object C for class A, though A is not
* serializable, but it's okay to serialize C.
*/
- static ObjectStreamClass lookupForClassObject (Class cl)
+ static ObjectStreamClass lookupForClassObject(Class cl)
{
if (cl == null)
return null;
- ObjectStreamClass osc = (ObjectStreamClass)classLookupTable.get (cl);
+ ObjectStreamClass osc = (ObjectStreamClass) classLookupTable.get(cl);
if (osc != null)
return osc;
else
- {
- osc = new ObjectStreamClass (cl);
- classLookupTable.put (cl, osc);
- return osc;
- }
+ {
+ osc = new ObjectStreamClass(cl);
+ classLookupTable.put(cl, osc);
+ return osc;
+ }
}
/**
- Returns the name of the class that this
- <code>ObjectStreamClass</code> represents.
- */
- public String getName ()
+ * Returns the name of the class that this
+ * <code>ObjectStreamClass</code> represents.
+ */
+ public String getName()
{
return name;
}
/**
- Returns the class that this <code>ObjectStreamClass</code>
- represents. Null could be returned if this
- <code>ObjectStreamClass</code> was read from an
- <code>ObjectInputStream</code> and the class it represents cannot
- be found or loaded.
-
- @see java.io.ObjectInputStream
- */
- public Class forClass ()
+ * Returns the class that this <code>ObjectStreamClass</code>
+ * represents. Null could be returned if this
+ * <code>ObjectStreamClass</code> was read from an
+ * <code>ObjectInputStream</code> and the class it represents cannot
+ * be found or loaded.
+ *
+ * @see java.io.ObjectInputStream
+ */
+ public Class forClass()
{
return clazz;
}
/**
- Returns the serial version stream-unique identifier for the class
- represented by this <code>ObjectStreamClass</code>. This SUID is
- either defined by the class as <code>static final long
- serialVersionUID</code> or is calculated as specified in
- Javasoft's "Object Serialization Specification" XXX: add reference
- */
- public long getSerialVersionUID ()
+ * Returns the serial version stream-unique identifier for the class
+ * represented by this <code>ObjectStreamClass</code>. This SUID is
+ * either defined by the class as <code>static final long
+ * serialVersionUID</code> or is calculated as specified in
+ * Javasoft's "Object Serialization Specification" XXX: add reference
+ */
+ public long getSerialVersionUID()
{
return uid;
}
@@ -145,10 +145,10 @@ public class ObjectStreamClass implements Serializable
// of the class represented by this ObjectStreamClass. The Fields
// are sorted by name.
// XXX doc
- public ObjectStreamField[] getFields ()
+ public ObjectStreamField[] getFields()
{
ObjectStreamField[] copy = new ObjectStreamField[ fields.length ];
- System.arraycopy (fields, 0, copy, 0, fields.length);
+ System.arraycopy(fields, 0, copy, 0, fields.length);
return copy;
}
@@ -158,8 +158,8 @@ public class ObjectStreamClass implements Serializable
// primitiveness.
public ObjectStreamField getField (String name)
{
- for (int i=0; i < fields.length; i++)
- if (fields[i].getName ().equals (name))
+ for (int i = 0; i < fields.length; i++)
+ if (fields[i].getName().equals(name))
return fields[i];
return null;
}
@@ -174,7 +174,7 @@ public class ObjectStreamClass implements Serializable
* @see #getSerialVersionUID()
* @see #getName()
*/
- public String toString ()
+ public String toString()
{
return "java.io.ObjectStreamClass< " + name + ", " + uid + " >";
}
@@ -187,7 +187,7 @@ public class ObjectStreamClass implements Serializable
//
// This method is used by the class to override default
// serialization behavior.
- boolean hasWriteMethod ()
+ boolean hasWriteMethod()
{
return (flags & ObjectStreamConstants.SC_WRITE_METHOD) != 0;
}
@@ -200,24 +200,24 @@ public class ObjectStreamClass implements Serializable
//
// This method is used by the class to override default
// serialization behavior.
- boolean hasReadMethod ()
+ boolean hasReadMethod()
{
- try
+ try
{
- Class[] readObjectParams = { ObjectInputStream.class };
- forClass ().getDeclaredMethod ("readObject", readObjectParams);
- return true;
+ Class[] readObjectParams = { ObjectInputStream.class };
+ forClass().getDeclaredMethod("readObject", readObjectParams);
+ return true;
}
- catch (NoSuchMethodException e)
+ catch (NoSuchMethodException e)
{
- return false;
+ return false;
}
}
// Returns true iff the class that this ObjectStreamClass represents
// implements Serializable but does *not* implement Externalizable.
- boolean isSerializable ()
+ boolean isSerializable()
{
return (flags & ObjectStreamConstants.SC_SERIALIZABLE) != 0;
}
@@ -225,7 +225,7 @@ public class ObjectStreamClass implements Serializable
// Returns true iff the class that this ObjectStreamClass represents
// implements Externalizable.
- boolean isExternalizable ()
+ boolean isExternalizable()
{
return (flags & ObjectStreamConstants.SC_EXTERNALIZABLE) != 0;
}
@@ -235,7 +235,7 @@ public class ObjectStreamClass implements Serializable
// class that is the superclass of the class this
// <code>ObjectStreamClass</code> represents. If the superclass is
// not Serializable, null is returned.
- ObjectStreamClass getSuper ()
+ ObjectStreamClass getSuper()
{
return superClass;
}
@@ -245,30 +245,30 @@ public class ObjectStreamClass implements Serializable
// classes of CLAZZ and CLAZZ itself in order from most super to
// CLAZZ. ObjectStreamClass[0] is the highest superclass of CLAZZ
// that is serializable.
- static ObjectStreamClass[] getObjectStreamClasses (Class clazz)
+ static ObjectStreamClass[] getObjectStreamClasses(Class clazz)
{
- ObjectStreamClass osc = ObjectStreamClass.lookup (clazz);
+ ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
if (osc == null)
return new ObjectStreamClass[0];
else
- {
- Vector oscs = new Vector ();
-
- while (osc != null)
{
- oscs.addElement (osc);
- osc = osc.getSuper ();
- }
+ Vector oscs = new Vector();
- int count = oscs.size ();
- ObjectStreamClass[] sorted_oscs = new ObjectStreamClass[ count ];
+ while (osc != null)
+ {
+ oscs.addElement (osc);
+ osc = osc.getSuper();
+ }
- for (int i = count - 1; i >= 0; i--)
- sorted_oscs[ count - i - 1 ] = (ObjectStreamClass)oscs.elementAt (i);
+ int count = oscs.size();
+ ObjectStreamClass[] sorted_oscs = new ObjectStreamClass[ count ];
- return sorted_oscs;
- }
+ for (int i = count - 1; i >= 0; i--)
+ sorted_oscs[ count - i - 1 ] = (ObjectStreamClass) oscs.elementAt(i);
+
+ return sorted_oscs;
+ }
}
@@ -276,14 +276,14 @@ public class ObjectStreamClass implements Serializable
// properties of the class represented by this ObjectStreamClass.
// The bit-flags that could be present are those defined in
// ObjectStreamConstants that begin with `SC_'
- int getFlags ()
+ int getFlags()
{
return flags;
}
- ObjectStreamClass (String name, long uid, byte flags,
- ObjectStreamField[] fields)
+ ObjectStreamClass(String name, long uid, byte flags,
+ ObjectStreamField[] fields)
{
this.name = name;
this.uid = uid;
@@ -302,11 +302,11 @@ public class ObjectStreamClass implements Serializable
* @throws InvalidClassException if an incompatibility between computed UID and
* already set UID is found.
*/
- void setClass (Class cl, ObjectStreamClass superClass) throws InvalidClassException
+ void setClass(Class cl, ObjectStreamClass superClass) throws InvalidClassException
{
this.clazz = cl;
- long class_uid = getClassUID (cl);
+ long class_uid = getClassUID(cl);
if (uid == 0)
uid = class_uid;
else
@@ -322,87 +322,89 @@ public class ObjectStreamClass implements Serializable
}
}
- isProxyClass = clazz != null && Proxy.isProxyClass (clazz);
+ isProxyClass = clazz != null && Proxy.isProxyClass(clazz);
this.superClass = superClass;
- calculateOffsets ();
-
+ calculateOffsets();
+
try
{
- ObjectStreamField[] exportedFields = getSerialPersistentFields (clazz);
-
- if (exportedFields == null)
- return;
-
- ObjectStreamField[] newFieldList = new ObjectStreamField[exportedFields.length + fields.length];
- int i, j, k;
-
- /* We now check the import fields against the exported fields.
- * There should not be contradiction (e.g. int x and String x)
- * but extra virtual fields can be added to the class.
- */
-
- Arrays.sort(exportedFields);
-
- i = 0; j = 0; k = 0;
- while (i < fields.length && j < exportedFields.length)
- {
- int comp = fields[i].getName().compareTo (exportedFields[j].getName());
- if (comp < 0)
- {
- newFieldList[k] = fields[i];
- fields[i].setPersistent(false);
- fields[i].setToSet(false);
- i++;
- }
- else if (comp > 0)
- {
- /* field not found in imported fields. We add it
- * in the list of supported fields.
- */
- newFieldList[k] = exportedFields[j];
- newFieldList[k].setPersistent(true);
- newFieldList[k].setToSet(false);
- j++;
- }
- else
- {
- if (!fields[i].getType().equals (exportedFields[j].getType()))
- throw new InvalidClassException ("serialPersistentFields must be compatible with" +
- " imported fields (about " + fields[i].getName() + ")");
- newFieldList[k] = fields[i];
- fields[i].setPersistent(true);
- i++;
- j++;
- }
- k++;
- }
-
- if (i < fields.length)
- for (; i < fields.length; i++, k++)
- {
- fields[i].setPersistent(false);
- fields[i].setToSet(false);
- newFieldList[k] = fields[i];
- }
- else
- if (j < exportedFields.length)
- for (; j < exportedFields.length; j++, k++)
- {
- exportedFields[j].setPersistent(true);
- exportedFields[j].setToSet(false);
- newFieldList[k] = exportedFields[j];
- }
-
- fields = new ObjectStreamField[k];
- System.arraycopy (newFieldList, 0, fields, 0, k);
+ ObjectStreamField[] exportedFields = getSerialPersistentFields (clazz);
+
+ if (exportedFields == null)
+ return;
+
+ ObjectStreamField[] newFieldList = new ObjectStreamField[exportedFields.length + fields.length];
+ int i, j, k;
+
+ /* We now check the import fields against the exported fields.
+ * There should not be contradiction (e.g. int x and String x)
+ * but extra virtual fields can be added to the class.
+ */
+
+ Arrays.sort(exportedFields);
+
+ i = 0; j = 0; k = 0;
+ while (i < fields.length && j < exportedFields.length)
+ {
+ int comp = fields[i].getName().compareTo(exportedFields[j].getName());
+
+ if (comp < 0)
+ {
+ newFieldList[k] = fields[i];
+ fields[i].setPersistent(false);
+ fields[i].setToSet(false);
+ i++;
+ }
+ else if (comp > 0)
+ {
+ /* field not found in imported fields. We add it
+ * in the list of supported fields.
+ */
+ newFieldList[k] = exportedFields[j];
+ newFieldList[k].setPersistent(true);
+ newFieldList[k].setToSet(false);
+ j++;
+ }
+ else
+ {
+ if (!fields[i].getType().equals(exportedFields[j].getType()))
+ throw new InvalidClassException
+ ("serialPersistentFields must be compatible with" +
+ " imported fields (about " + fields[i].getName() + ")");
+ newFieldList[k] = fields[i];
+ fields[i].setPersistent(true);
+ i++;
+ j++;
+ }
+ k++;
+ }
+
+ if (i < fields.length)
+ for (;i<fields.length;i++,k++)
+ {
+ fields[i].setPersistent(false);
+ fields[i].setToSet(false);
+ newFieldList[k] = fields[i];
+ }
+ else
+ if (j < exportedFields.length)
+ for (;j<exportedFields.length;j++,k++)
+ {
+ exportedFields[j].setPersistent(true);
+ exportedFields[j].setToSet(false);
+ newFieldList[k] = exportedFields[j];
+ }
+
+ fields = new ObjectStreamField[k];
+ System.arraycopy(newFieldList, 0, fields, 0, k);
}
catch (NoSuchFieldException ignore)
{
- return;
+ return;
}
catch (IllegalAccessException ignore)
{
- return;
+ return;
}
}
@@ -411,313 +413,345 @@ public class ObjectStreamClass implements Serializable
superClass = osc;
}
-
- void calculateOffsets ()
+ void calculateOffsets()
{
int i;
ObjectStreamField field;
primFieldSize = 0;
int fcount = fields.length;
for (i = 0; i < fcount; ++ i)
- {
- field = fields[i];
-
- if (! field.isPrimitive ())
- break;
-
- field.setOffset (primFieldSize);
- switch (field.getTypeCode ())
{
- case 'B':
- case 'Z':
- ++ primFieldSize;
- break;
- case 'C':
- case 'S':
- primFieldSize += 2;
- break;
- case 'I':
- case 'F':
- primFieldSize += 4;
- break;
- case 'D':
- case 'J':
- primFieldSize += 8;
+ field = fields[i];
+
+ if (! field.isPrimitive())
break;
+
+ field.setOffset(primFieldSize);
+ switch (field.getTypeCode())
+ {
+ case 'B':
+ case 'Z':
+ ++ primFieldSize;
+ break;
+ case 'C':
+ case 'S':
+ primFieldSize += 2;
+ break;
+ case 'I':
+ case 'F':
+ primFieldSize += 4;
+ break;
+ case 'D':
+ case 'J':
+ primFieldSize += 8;
+ break;
+ }
}
- }
for (objectFieldCount = 0; i < fcount; ++ i)
- fields[i].setOffset (objectFieldCount++);
+ fields[i].setOffset(objectFieldCount++);
}
- private ObjectStreamClass (Class cl)
+ private ObjectStreamClass(Class cl)
{
uid = 0;
flags = 0;
- isProxyClass = Proxy.isProxyClass (cl);
+ isProxyClass = Proxy.isProxyClass(cl);
clazz = cl;
- name = cl.getName ();
- setFlags (cl);
- setFields (cl);
+ name = cl.getName();
+ setFlags(cl);
+ setFields(cl);
// to those class nonserializable, its uid field is 0
- if ( (Serializable.class).isAssignableFrom (cl) && !isProxyClass)
- uid = getClassUID (cl);
- superClass = lookup (cl.getSuperclass ());
+ if ( (Serializable.class).isAssignableFrom(cl) && !isProxyClass)
+ uid = getClassUID(cl);
+ superClass = lookup(cl.getSuperclass());
}
// Sets bits in flags according to features of CL.
- private void setFlags (Class cl)
+ private void setFlags(Class cl)
{
- if ((java.io.Externalizable.class).isAssignableFrom (cl))
+ if ((java.io.Externalizable.class).isAssignableFrom(cl))
flags |= ObjectStreamConstants.SC_EXTERNALIZABLE;
- else if ((java.io.Serializable.class).isAssignableFrom (cl))
+ else if ((java.io.Serializable.class).isAssignableFrom(cl))
// only set this bit if CL is NOT Externalizable
flags |= ObjectStreamConstants.SC_SERIALIZABLE;
try
- {
- Method writeMethod = cl.getDeclaredMethod ("writeObject",
- writeMethodArgTypes);
- int modifiers = writeMethod.getModifiers ();
-
- if (writeMethod.getReturnType () == Void.TYPE
- && Modifier.isPrivate (modifiers)
- && !Modifier.isStatic (modifiers))
- flags |= ObjectStreamConstants.SC_WRITE_METHOD;
- }
- catch (NoSuchMethodException oh_well)
- {}
+ {
+ Method writeMethod = cl.getDeclaredMethod("writeObject",
+ writeMethodArgTypes);
+ int modifiers = writeMethod.getModifiers();
+
+ if (writeMethod.getReturnType() == Void.TYPE
+ && Modifier.isPrivate(modifiers)
+ && !Modifier.isStatic(modifiers))
+ flags |= ObjectStreamConstants.SC_WRITE_METHOD;
+ }
+ catch(NoSuchMethodException oh_well)
+ {
+ }
}
// Sets fields to be a sorted array of the serializable fields of
// clazz.
- private void setFields (Class cl)
+ private void setFields(Class cl)
{
- if (! isSerializable () || isExternalizable ())
- {
- fields = NO_FIELDS;
- return;
- }
+ if (!isSerializable() || isExternalizable())
+ {
+ fields = NO_FIELDS;
+ return;
+ }
try
- {
- Field serialPersistentFields
- = cl.getDeclaredField ("serialPersistentFields");
- serialPersistentFields.setAccessible(true);
- int modifiers = serialPersistentFields.getModifiers ();
-
- if (Modifier.isStatic (modifiers)
- && Modifier.isFinal (modifiers)
- && Modifier.isPrivate (modifiers))
{
- fields = getSerialPersistentFields (cl);
- Arrays.sort (fields);
- calculateOffsets ();
- return;
+ Field serialPersistentFields =
+ cl.getDeclaredField("serialPersistentFields");
+ serialPersistentFields.setAccessible(true);
+ int modifiers = serialPersistentFields.getModifiers();
+
+ if (Modifier.isStatic(modifiers)
+ && Modifier.isFinal(modifiers)
+ && Modifier.isPrivate(modifiers))
+ {
+ fields = getSerialPersistentFields(cl);
+ if (fields != null)
+ {
+ Arrays.sort (fields);
+ calculateOffsets();
+ return;
+ }
+ }
}
- }
catch (NoSuchFieldException ignore)
- {}
+ {
+ }
catch (IllegalAccessException ignore)
{
}
int num_good_fields = 0;
- Field[] all_fields = cl.getDeclaredFields ();
+ Field[] all_fields = cl.getDeclaredFields();
int modifiers;
// set non-serializable fields to null in all_fields
- for (int i=0; i < all_fields.length; i++)
- {
- modifiers = all_fields[i].getModifiers ();
- if (Modifier.isTransient (modifiers)
- || Modifier.isStatic (modifiers))
- all_fields[i] = null;
- else
- num_good_fields++;
- }
+ for (int i = 0; i < all_fields.length; i++)
+ {
+ modifiers = all_fields[i].getModifiers();
+ if (Modifier.isTransient(modifiers)
+ || Modifier.isStatic(modifiers))
+ all_fields[i] = null;
+ else
+ num_good_fields++;
+ }
// make a copy of serializable (non-null) fields
fields = new ObjectStreamField[ num_good_fields ];
- for (int from=0, to=0; from < all_fields.length; from++)
+ for (int from = 0, to = 0; from < all_fields.length; from++)
if (all_fields[from] != null)
- {
- Field f = all_fields[from];
- fields[to] = new ObjectStreamField (f.getName (), f.getType ());
- to++;
- }
+ {
+ Field f = all_fields[from];
+ fields[to] = new ObjectStreamField(f.getName(), f.getType());
+ to++;
+ }
- Arrays.sort (fields);
- calculateOffsets ();
+ Arrays.sort(fields);
+ calculateOffsets();
}
// Returns the serial version UID defined by class, or if that
// isn't present, calculates value of serial version UID.
- private long getClassUID (Class cl)
+ private long getClassUID(Class cl)
{
try
- {
- // Use getDeclaredField rather than getField, since serialVersionUID
- // may not be public AND we only want the serialVersionUID of this
- // class, not a superclass or interface.
- Field suid = cl.getDeclaredField ("serialVersionUID");
- suid.setAccessible(true);
- int modifiers = suid.getModifiers ();
-
- if (Modifier.isStatic (modifiers)
- && Modifier.isFinal (modifiers)
- && suid.getType() == Long.TYPE)
- return suid.getLong (null);
- }
+ {
+ // Use getDeclaredField rather than getField, since serialVersionUID
+ // may not be public AND we only want the serialVersionUID of this
+ // class, not a superclass or interface.
+ Field suid = cl.getDeclaredField("serialVersionUID");
+ suid.setAccessible(true);
+ int modifiers = suid.getModifiers();
+
+ if (Modifier.isStatic(modifiers)
+ && Modifier.isFinal(modifiers)
+ && suid.getType() == Long.TYPE)
+ return suid.getLong(null);
+ }
catch (NoSuchFieldException ignore)
- {}
+ {
+ }
catch (IllegalAccessException ignore)
- {}
+ {
+ }
// cl didn't define serialVersionUID, so we have to compute it
try
- {
- MessageDigest md;
- try
- {
- md = MessageDigest.getInstance ("SHA");
- }
- catch (NoSuchAlgorithmException e)
- {
- // If a provider already provides SHA, use it; otherwise, use this.
- Gnu gnuProvider = new Gnu();
- Security.addProvider(gnuProvider);
- md = MessageDigest.getInstance ("SHA");
- }
+ {
+ MessageDigest md;
+ try
+ {
+ md = MessageDigest.getInstance("SHA");
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ // If a provider already provides SHA, use it; otherwise, use this.
+ Gnu gnuProvider = new Gnu();
+ Security.addProvider(gnuProvider);
+ md = MessageDigest.getInstance("SHA");
+ }
- DigestOutputStream digest_out =
- new DigestOutputStream (nullOutputStream, md);
- DataOutputStream data_out = new DataOutputStream (digest_out);
+ DigestOutputStream digest_out =
+ new DigestOutputStream(nullOutputStream, md);
+ DataOutputStream data_out = new DataOutputStream(digest_out);
- data_out.writeUTF (cl.getName ());
+ data_out.writeUTF(cl.getName());
- int modifiers = cl.getModifiers ();
- // just look at interesting bits
- modifiers = modifiers & (Modifier.ABSTRACT | Modifier.FINAL
- | Modifier.INTERFACE | Modifier.PUBLIC);
- data_out.writeInt (modifiers);
+ int modifiers = cl.getModifiers();
+ // just look at interesting bits
+ modifiers = modifiers & (Modifier.ABSTRACT | Modifier.FINAL
+ | Modifier.INTERFACE | Modifier.PUBLIC);
+ data_out.writeInt(modifiers);
- // Pretend that an array has no interfaces, because when array
- // serialization was defined (JDK 1.1), arrays didn't have it.
- if (! cl.isArray ())
- {
- Class[] interfaces = cl.getInterfaces ();
- Arrays.sort (interfaces, interfaceComparator);
- for (int i=0; i < interfaces.length; i++)
- data_out.writeUTF (interfaces[i].getName ());
- }
+ // Pretend that an array has no interfaces, because when array
+ // serialization was defined (JDK 1.1), arrays didn't have it.
+ if (! cl.isArray())
+ {
+ Class[] interfaces = cl.getInterfaces();
+ Arrays.sort(interfaces, interfaceComparator);
+ for (int i = 0; i < interfaces.length; i++)
+ data_out.writeUTF(interfaces[i].getName());
+ }
- Field field;
- Field[] fields = cl.getDeclaredFields ();
- Arrays.sort (fields, memberComparator);
- for (int i=0; i < fields.length; i++)
- {
- field = fields[i];
- modifiers = field.getModifiers ();
- if (Modifier.isPrivate (modifiers)
- && (Modifier.isStatic (modifiers)
- || Modifier.isTransient (modifiers)))
- continue;
-
- data_out.writeUTF (field.getName ());
- data_out.writeInt (modifiers);
- data_out.writeUTF (TypeSignature.getEncodingOfClass (field.getType ()));
- }
+ Field field;
+ Field[] fields = cl.getDeclaredFields();
+ Arrays.sort(fields, memberComparator);
+ for (int i = 0; i < fields.length; i++)
+ {
+ field = fields[i];
+ modifiers = field.getModifiers();
+ if (Modifier.isPrivate(modifiers)
+ && (Modifier.isStatic(modifiers)
+ || Modifier.isTransient(modifiers)))
+ continue;
+
+ data_out.writeUTF(field.getName());
+ data_out.writeInt(modifiers);
+ data_out.writeUTF(TypeSignature.getEncodingOfClass (field.getType()));
+ }
- // write class initializer method if present
- if (VMObjectStreamClass.hasClassInitializer (cl))
- {
- data_out.writeUTF ("<clinit>");
- data_out.writeInt (Modifier.STATIC);
- data_out.writeUTF ("()V");
- }
+ // write class initializer method if present
+ if (VMObjectStreamClass.hasClassInitializer(cl))
+ {
+ data_out.writeUTF("<clinit>");
+ data_out.writeInt(Modifier.STATIC);
+ data_out.writeUTF("()V");
+ }
- Constructor constructor;
- Constructor[] constructors = cl.getDeclaredConstructors ();
- Arrays.sort (constructors, memberComparator);
- for (int i=0; i < constructors.length; i++)
- {
- constructor = constructors[i];
- modifiers = constructor.getModifiers ();
- if (Modifier.isPrivate (modifiers))
- continue;
-
- data_out.writeUTF ("<init>");
- data_out.writeInt (modifiers);
-
- // the replacement of '/' with '.' was needed to make computed
- // SUID's agree with those computed by JDK
- data_out.writeUTF (
- TypeSignature.getEncodingOfConstructor (constructor).replace ('/','.'));
- }
+ Constructor constructor;
+ Constructor[] constructors = cl.getDeclaredConstructors();
+ Arrays.sort (constructors, memberComparator);
+ for (int i = 0; i < constructors.length; i++)
+ {
+ constructor = constructors[i];
+ modifiers = constructor.getModifiers();
+ if (Modifier.isPrivate(modifiers))
+ continue;
+
+ data_out.writeUTF("<init>");
+ data_out.writeInt(modifiers);
+
+ // the replacement of '/' with '.' was needed to make computed
+ // SUID's agree with those computed by JDK
+ data_out.writeUTF
+ (TypeSignature.getEncodingOfConstructor(constructor).replace('/','.'));
+ }
- Method method;
- Method[] methods = cl.getDeclaredMethods ();
- Arrays.sort (methods, memberComparator);
- for (int i=0; i < methods.length; i++)
- {
- method = methods[i];
- modifiers = method.getModifiers ();
- if (Modifier.isPrivate (modifiers))
- continue;
-
- data_out.writeUTF (method.getName ());
- data_out.writeInt (modifiers);
-
- // the replacement of '/' with '.' was needed to make computed
- // SUID's agree with those computed by JDK
- data_out.writeUTF (
- TypeSignature.getEncodingOfMethod (method).replace ('/', '.'));
- }
+ Method method;
+ Method[] methods = cl.getDeclaredMethods();
+ Arrays.sort(methods, memberComparator);
+ for (int i = 0; i < methods.length; i++)
+ {
+ method = methods[i];
+ modifiers = method.getModifiers();
+ if (Modifier.isPrivate(modifiers))
+ continue;
+
+ data_out.writeUTF(method.getName());
+ data_out.writeInt(modifiers);
+
+ // the replacement of '/' with '.' was needed to make computed
+ // SUID's agree with those computed by JDK
+ data_out.writeUTF
+ (TypeSignature.getEncodingOfMethod(method).replace('/', '.'));
+ }
- data_out.close ();
- byte[] sha = md.digest ();
- long result = 0;
- int len = sha.length < 8 ? sha.length : 8;
- for (int i=0; i < len; i++)
- result += (long)(sha[i] & 0xFF) << (8 * i);
+ data_out.close();
+ byte[] sha = md.digest();
+ long result = 0;
+ int len = sha.length < 8 ? sha.length : 8;
+ for (int i = 0; i < len; i++)
+ result += (long) (sha[i] & 0xFF) << (8 * i);
- return result;
- }
+ return result;
+ }
catch (NoSuchAlgorithmException e)
- {
- throw new RuntimeException ("The SHA algorithm was not found to use in computing the Serial Version UID for class "
- + cl.getName (), e);
- }
+ {
+ throw new RuntimeException
+ ("The SHA algorithm was not found to use in computing the Serial Version UID for class "
+ + cl.getName(), e);
+ }
catch (IOException ioe)
- {
- throw new RuntimeException (ioe);
- }
+ {
+ throw new RuntimeException(ioe);
+ }
}
- // Returns the value of CLAZZ's private static final field named
- // `serialPersistentFields'.
- private ObjectStreamField[] getSerialPersistentFields (Class clazz)
+ /**
+ * Returns the value of CLAZZ's private static final field named
+ * `serialPersistentFields'. It performs some sanity checks before
+ * returning the real array. Besides, the returned array is a clean
+ * copy of the original. So it can be modified.
+ *
+ * @param clazz Class to retrieve 'serialPersistentFields' from.
+ * @return The content of 'serialPersistentFields'.
+ */
+ private ObjectStreamField[] getSerialPersistentFields(Class clazz)
throws NoSuchFieldException, IllegalAccessException
{
+ ObjectStreamField[] fieldsArray = null;
+ ObjectStreamField[] o;
+
// Use getDeclaredField rather than getField for the same reason
// as above in getDefinedSUID.
Field f = clazz.getDeclaredField("serialPersistentFields");
f.setAccessible(true);
- return (ObjectStreamField[]) f.get(null);
+
+ int modifiers = f.getModifiers();
+ if (!(Modifier.isStatic(modifiers) &&
+ Modifier.isFinal(modifiers) &&
+ Modifier.isPrivate(modifiers)))
+ return null;
+
+ o = (ObjectStreamField[]) f.get(null);
+
+ if (o == null)
+ return null;
+
+ fieldsArray = new ObjectStreamField[ o.length ];
+ System.arraycopy(o, 0, fieldsArray, 0, o.length);
+
+ return fieldsArray;
}
public static final ObjectStreamField[] NO_FIELDS = {};
- private static Hashtable classLookupTable = new Hashtable ();
- private static final NullOutputStream nullOutputStream = new NullOutputStream ();
- private static final Comparator interfaceComparator = new InterfaceComparator ();
- private static final Comparator memberComparator = new MemberComparator ();
+ private static Hashtable classLookupTable = new Hashtable();
+ private static final NullOutputStream nullOutputStream = new NullOutputStream();
+ private static final Comparator interfaceComparator = new InterfaceComparator();
+ private static final Comparator memberComparator = new MemberComparator();
private static final
Class[] writeMethodArgTypes = { java.io.ObjectOutputStream.class };
@@ -747,9 +781,9 @@ public class ObjectStreamClass implements Serializable
// interfaces are compared only by name
class InterfaceComparator implements Comparator
{
- public int compare (Object o1, Object o2)
+ public int compare(Object o1, Object o2)
{
- return ((Class)o1).getName ().compareTo (((Class)o2).getName ());
+ return ((Class) o1).getName().compareTo(((Class) o2).getName());
}
}
@@ -758,16 +792,16 @@ class InterfaceComparator implements Comparator
// conflicts are resolved by comparing type signatures
class MemberComparator implements Comparator
{
- public int compare (Object o1, Object o2)
+ public int compare(Object o1, Object o2)
{
- Member m1 = (Member)o1;
- Member m2 = (Member)o2;
+ Member m1 = (Member) o1;
+ Member m2 = (Member) o2;
- int comp = m1.getName ().compareTo (m2.getName ());
+ int comp = m1.getName().compareTo(m2.getName());
if (comp == 0)
- return TypeSignature.getEncodingOfMember (m1).
- compareTo (TypeSignature.getEncodingOfMember (m2));
+ return TypeSignature.getEncodingOfMember(m1).
+ compareTo(TypeSignature.getEncodingOfMember(m2));
else
return comp;
}
diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java
index a691d208498..597e641a346 100644
--- a/libjava/java/net/ServerSocket.java
+++ b/libjava/java/net/ServerSocket.java
@@ -221,14 +221,20 @@ public class ServerSocket
throw new IllegalArgumentException ("Address type not supported");
InetSocketAddress tmp = (InetSocketAddress) endpoint;
-
+
SecurityManager s = System.getSecurityManager ();
if (s != null)
s.checkListen (tmp.getPort ());
+ InetAddress addr = tmp.getAddress();
+
+ // Initialize addr with 0.0.0.0.
+ if (addr == null)
+ addr = InetAddress.ANY_IF;
+
try
{
- impl.bind (tmp.getAddress (), tmp.getPort ());
+ impl.bind(addr, tmp.getPort());
impl.listen(backlog);
bound = true;
}
diff --git a/libjava/java/rmi/Naming.java b/libjava/java/rmi/Naming.java
index 2dd50d32804..1d2e68b982f 100644
--- a/libjava/java/rmi/Naming.java
+++ b/libjava/java/rmi/Naming.java
@@ -62,7 +62,14 @@ public static Remote lookup(String name) throws NotBoundException, MalformedURLE
// hack to accept "rmi://host:port/service" strings
if(name.startsWith("rmi:")){ name = name.substring(4); }
URL u = new URL("http:" + name);
- return (getRegistry(u).lookup(u.getFile().substring(1)));
+ String filename = u.getFile();
+
+ // If the filename begins with a slash we must cut it for
+ // name resolution.
+ if (filename.charAt(0) == '/')
+ return (getRegistry(u).lookup(filename.substring(1)));
+ else
+ return (getRegistry(u).lookup(filename));
}
/**
@@ -75,7 +82,13 @@ public static Remote lookup(String name) throws NotBoundException, MalformedURLE
*/
public static void bind(String name, Remote obj) throws AlreadyBoundException, MalformedURLException, RemoteException {
URL u = new URL("http:" + name);
- getRegistry(u).bind(u.getFile().substring(1), obj);
+ String filename = u.getFile();
+ // If the filename begins with a slash we must cut it for
+ // name resolution.
+ if (filename.charAt(0) == '/')
+ getRegistry(u).bind(filename.substring(1), obj);
+ else
+ getRegistry(u).bind(filename, obj);
}
/**
@@ -87,7 +100,13 @@ public static void bind(String name, Remote obj) throws AlreadyBoundException, M
*/
public static void unbind(String name) throws RemoteException, NotBoundException, MalformedURLException {
URL u = new URL("http:" + name);
- getRegistry(u).unbind(u.getFile().substring(1));
+ String filename = u.getFile();
+ // If the filename begins with a slash we must cut it for
+ // name resolution.
+ if (filename.charAt(0) == '/')
+ getRegistry(u).unbind(filename.substring(1));
+ else
+ getRegistry(u).unbind(filename);
}
/**
@@ -100,7 +119,13 @@ public static void unbind(String name) throws RemoteException, NotBoundException
*/
public static void rebind(String name, Remote obj) throws RemoteException, MalformedURLException {
URL u = new URL("http:" + name);
- getRegistry(u).rebind(u.getFile().substring(1), obj);
+ String filename = u.getFile();
+ // If the filename begins with a slash we must cut it for
+ // name resolution.
+ if (filename.charAt(0) == '/')
+ getRegistry(u).rebind(filename.substring(1), obj);
+ else
+ getRegistry(u).rebind(filename, obj);
}
/**
diff --git a/libjava/javax/print/attribute/ResolutionSyntax.java b/libjava/javax/print/attribute/ResolutionSyntax.java
index 150e19856b5..592d995df7d 100644
--- a/libjava/javax/print/attribute/ResolutionSyntax.java
+++ b/libjava/javax/print/attribute/ResolutionSyntax.java
@@ -75,7 +75,7 @@ public abstract class ResolutionSyntax
if (crossFeedResolution < 1
|| feedResolution < 1
|| units < 1)
- throw new IllegalArgumentException("no argument may be less then 1");
+ throw new IllegalArgumentException("no argument may be less than 1");
this.crossFeedResolution = crossFeedResolution * units;
this.feedResolution = feedResolution * units;
diff --git a/libjava/javax/print/attribute/SetOfIntegerSyntax.java b/libjava/javax/print/attribute/SetOfIntegerSyntax.java
index 3204187afd4..d4e7fde00c2 100644
--- a/libjava/javax/print/attribute/SetOfIntegerSyntax.java
+++ b/libjava/javax/print/attribute/SetOfIntegerSyntax.java
@@ -89,7 +89,7 @@ public abstract class SetOfIntegerSyntax
protected SetOfIntegerSyntax(int member)
{
if (member < 0)
- throw new IllegalArgumentException("member may not be less then 0");
+ throw new IllegalArgumentException("member may not be less than 0");
this.members = new int[][]{{member, member}};
}
diff --git a/libjava/javax/print/attribute/Size2DSyntax.java b/libjava/javax/print/attribute/Size2DSyntax.java
index 94743181a76..4b71fd6aae9 100644
--- a/libjava/javax/print/attribute/Size2DSyntax.java
+++ b/libjava/javax/print/attribute/Size2DSyntax.java
@@ -69,7 +69,7 @@ public abstract class Size2DSyntax implements Cloneable, Serializable
protected Size2DSyntax(float x, float y, int units)
{
if (x < 0.0f || y < 0.0f)
- throw new IllegalArgumentException("x and/or y may not be less then 0");
+ throw new IllegalArgumentException("x and/or y may not be less than 0");
if (units < 1)
throw new IllegalArgumentException("units may not be less then 1");
diff --git a/libjava/javax/print/attribute/standard/Copies.java b/libjava/javax/print/attribute/standard/Copies.java
index 8c7485da110..863c11ab9e3 100644
--- a/libjava/javax/print/attribute/standard/Copies.java
+++ b/libjava/javax/print/attribute/standard/Copies.java
@@ -61,7 +61,7 @@ public final class Copies extends IntegerSyntax
super(value);
if (value < 1)
- throw new IllegalArgumentException("value may not be less then 1");
+ throw new IllegalArgumentException("value may not be less than 1");
}
/**
diff --git a/libjava/javax/print/attribute/standard/JobImpressions.java b/libjava/javax/print/attribute/standard/JobImpressions.java
index 41fb3227b39..3c99d4fc2be 100644
--- a/libjava/javax/print/attribute/standard/JobImpressions.java
+++ b/libjava/javax/print/attribute/standard/JobImpressions.java
@@ -61,7 +61,7 @@ public final class JobImpressions extends IntegerSyntax
super(value);
if (value < 0)
- throw new IllegalArgumentException("value may not be less then 0");
+ throw new IllegalArgumentException("value may not be less than 0");
}
/**
diff --git a/libjava/javax/print/attribute/standard/JobMediaSheets.java b/libjava/javax/print/attribute/standard/JobMediaSheets.java
index 4734189b869..ec90bc4383a 100644
--- a/libjava/javax/print/attribute/standard/JobMediaSheets.java
+++ b/libjava/javax/print/attribute/standard/JobMediaSheets.java
@@ -61,7 +61,7 @@ public class JobMediaSheets extends IntegerSyntax
super(value);
if (value < 0)
- throw new IllegalArgumentException("value may not be less then 0");
+ throw new IllegalArgumentException("value may not be less than 0");
}
/**
diff --git a/libjava/javax/print/attribute/standard/NumberOfDocuments.java b/libjava/javax/print/attribute/standard/NumberOfDocuments.java
index 37f67dc3c85..98c2f5a63aa 100644
--- a/libjava/javax/print/attribute/standard/NumberOfDocuments.java
+++ b/libjava/javax/print/attribute/standard/NumberOfDocuments.java
@@ -60,7 +60,7 @@ public final class NumberOfDocuments extends IntegerSyntax
super(value);
if (value < 0)
- throw new IllegalArgumentException("value may not be less then 0");
+ throw new IllegalArgumentException("value may not be less than 0");
}
/**
diff --git a/libjava/javax/print/attribute/standard/NumberOfInterveningJobs.java b/libjava/javax/print/attribute/standard/NumberOfInterveningJobs.java
index f07691adde2..865b774a829 100644
--- a/libjava/javax/print/attribute/standard/NumberOfInterveningJobs.java
+++ b/libjava/javax/print/attribute/standard/NumberOfInterveningJobs.java
@@ -60,7 +60,7 @@ public final class NumberOfInterveningJobs extends IntegerSyntax
super(value);
if (value < 0)
- throw new IllegalArgumentException("value may not be less then 0");
+ throw new IllegalArgumentException("value may not be less than 0");
}
/**
diff --git a/libjava/javax/print/attribute/standard/PagesPerMinute.java b/libjava/javax/print/attribute/standard/PagesPerMinute.java
index 70152757069..3a50493933c 100644
--- a/libjava/javax/print/attribute/standard/PagesPerMinute.java
+++ b/libjava/javax/print/attribute/standard/PagesPerMinute.java
@@ -60,7 +60,7 @@ public final class PagesPerMinute extends IntegerSyntax
super(value);
if (value < 0)
- throw new IllegalArgumentException("value may not be less then 0");
+ throw new IllegalArgumentException("value may not be less than 0");
}
/**
diff --git a/libjava/javax/print/attribute/standard/PagesPerMinuteColor.java b/libjava/javax/print/attribute/standard/PagesPerMinuteColor.java
index a2b063ce817..ea4a2909f25 100644
--- a/libjava/javax/print/attribute/standard/PagesPerMinuteColor.java
+++ b/libjava/javax/print/attribute/standard/PagesPerMinuteColor.java
@@ -60,7 +60,7 @@ public final class PagesPerMinuteColor extends IntegerSyntax
super(value);
if (value < 0)
- throw new IllegalArgumentException("value may not be less then 0");
+ throw new IllegalArgumentException("value may not be less than 0");
}
/**
diff --git a/libjava/javax/print/attribute/standard/QueuedJobCount.java b/libjava/javax/print/attribute/standard/QueuedJobCount.java
index 8b00bf01249..1b03151b196 100644
--- a/libjava/javax/print/attribute/standard/QueuedJobCount.java
+++ b/libjava/javax/print/attribute/standard/QueuedJobCount.java
@@ -60,7 +60,7 @@ public final class QueuedJobCount extends IntegerSyntax
super(value);
if (value < 0)
- throw new IllegalArgumentException("value may not be less then 0");
+ throw new IllegalArgumentException("value may not be less than 0");
}
/**
diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
index c57cfd1217c..068cf1e4254 100644
--- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
+++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
@@ -41,8 +41,9 @@ exception statement from your version. */
static void connect_choice_item_selectable_hook (JNIEnv *env,
jobject peer_obj,
- GtkItem *item,
- jobject item_obj);
+ GtkItem *menuitem,
+ const char *label);
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkChoicePeer_create
(JNIEnv *env, jobject obj)
@@ -101,14 +102,13 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_append
label = (*env)->GetStringUTFChars (env, item, NULL);
menuitem = gtk_menu_item_new_with_label (label);
-
- (*env)->ReleaseStringUTFChars (env, item, label);
-
gtk_menu_append (menu, menuitem);
gtk_widget_show (menuitem);
connect_choice_item_selectable_hook (env, obj,
- GTK_ITEM (menuitem), item);
+ GTK_ITEM (menuitem), label);
+
+ (*env)->ReleaseStringUTFChars (env, item, label);
}
if (need_set_history)
@@ -139,7 +139,8 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_add
menuitem = gtk_menu_item_new_with_label (label);
gtk_menu_insert (GTK_MENU (menu), menuitem, index);
gtk_widget_show (menuitem);
- connect_choice_item_selectable_hook (env, obj, GTK_ITEM (menuitem), item);
+
+ connect_choice_item_selectable_hook (env, obj, GTK_ITEM (menuitem), label);
if (need_set_history)
gtk_option_menu_set_history (GTK_OPTION_MENU (ptr), 0);
@@ -155,14 +156,19 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_remove
{
void *ptr;
GtkContainer *menu;
+ GtkWidget *menuitem;
GList *children;
ptr = NSA_GET_PTR (env, obj);
gdk_threads_enter ();
+
menu = GTK_CONTAINER (gtk_option_menu_get_menu (GTK_OPTION_MENU (ptr)));
children = gtk_container_children (menu);
- gtk_container_remove (menu, GTK_WIDGET (g_list_nth (children, index)->data));
+ menuitem = GTK_WIDGET (g_list_nth (children, index)->data);
+ gtk_container_remove (menu, menuitem);
+ gtk_widget_destroy (menuitem);
+
gdk_threads_leave ();
}
@@ -179,38 +185,49 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_select
gdk_threads_leave ();
}
-
static void
item_activate (GtkItem *item __attribute__((unused)),
struct item_event_hook_info *ie)
{
gdk_threads_leave ();
+
+ jstring label = (*gdk_env)->NewStringUTF (gdk_env, ie->label);
(*gdk_env)->CallVoidMethod (gdk_env, ie->peer_obj,
- postItemEventID,
- ie->item_obj,
+ choicePostItemEventID,
+ label,
(jint) AWT_ITEM_SELECTED);
gdk_threads_enter ();
}
static void
-connect_choice_item_selectable_hook (JNIEnv *env, jobject peer_obj,
- GtkItem *item, jobject item_obj)
+item_removed (gpointer data,
+ GClosure gc __attribute__((unused)))
+{
+ struct item_event_hook_info *ie = data;
+
+ free (ie->label);
+ free (ie);
+}
+
+static void
+connect_choice_item_selectable_hook (JNIEnv *env,
+ jobject peer_obj,
+ GtkItem *menuitem,
+ const char *label)
{
struct item_event_hook_info *ie;
jobject *peer_objGlobPtr;
- jobject *item_objGlobPtr;
ie = (struct item_event_hook_info *)
malloc (sizeof (struct item_event_hook_info));
peer_objGlobPtr = NSA_GET_GLOBAL_REF (env, peer_obj);
g_assert (peer_objGlobPtr);
- item_objGlobPtr = NSA_GET_GLOBAL_REF (env, item_obj);
- g_assert (item_objGlobPtr);
ie->peer_obj = *peer_objGlobPtr;
- ie->item_obj = *item_objGlobPtr;
+ ie->label = strdup (label);
- g_signal_connect (G_OBJECT (item), "activate",
- GTK_SIGNAL_FUNC (item_activate), ie);
+ g_signal_connect_data (G_OBJECT (menuitem), "activate",
+ GTK_SIGNAL_FUNC (item_activate), ie,
+ (GClosureNotify) item_removed, 0);
}
diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
index ed6107b3729..bad4a516884 100644
--- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
+++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
@@ -56,6 +56,7 @@ jmethodID postKeyEventID;
jmethodID postFocusEventID;
jmethodID postAdjustmentEventID;
jmethodID postItemEventID;
+jmethodID choicePostItemEventID;
jmethodID postListItemEventID;
jmethodID postTextEventID;
jmethodID postWindowEventID;
@@ -80,7 +81,7 @@ Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz)
char **argv;
char *homedir, *rcpath = NULL;
/* jclass gtkgenericpeer; */
- jclass gtkcomponentpeer, gtkwindowpeer, gtkscrollbarpeer, gtklistpeer,
+ jclass gtkcomponentpeer, gtkchoicepeer, gtkwindowpeer, gtkscrollbarpeer, gtklistpeer,
gtkmenuitempeer, gtktextcomponentpeer, window;
NSA_INIT (env, clazz);
@@ -139,6 +140,8 @@ Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz)
gtkcomponentpeer = (*env)->FindClass (env,
"gnu/java/awt/peer/gtk/GtkComponentPeer");
+ gtkchoicepeer = (*env)->FindClass (env,
+ "gnu/java/awt/peer/gtk/GtkChoicePeer");
gtkwindowpeer = (*env)->FindClass (env,
"gnu/java/awt/peer/gtk/GtkWindowPeer");
gtkscrollbarpeer = (*env)->FindClass (env,
@@ -181,6 +184,9 @@ Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz)
postItemEventID = (*env)->GetMethodID (env, gtkcomponentpeer,
"postItemEvent",
"(Ljava/lang/Object;I)V");
+ choicePostItemEventID = (*env)->GetMethodID (env, gtkchoicepeer,
+ "choicePostItemEvent",
+ "(Ljava/lang/String;I)V");
postListItemEventID = (*env)->GetMethodID (env, gtklistpeer,
"postItemEvent",
"(II)V");
diff --git a/libjava/jni/gtk-peer/gtkpeer.h b/libjava/jni/gtk-peer/gtkpeer.h
index a35c99b69e0..d552e687c9b 100644
--- a/libjava/jni/gtk-peer/gtkpeer.h
+++ b/libjava/jni/gtk-peer/gtkpeer.h
@@ -395,6 +395,7 @@ extern jmethodID postExposeEventID;
extern jmethodID postKeyEventID;
extern jmethodID postFocusEventID;
extern jmethodID postAdjustmentEventID;
+extern jmethodID choicePostItemEventID;
extern jmethodID postItemEventID;
extern jmethodID postListItemEventID;
extern jmethodID postTextEventID;
@@ -424,7 +425,7 @@ jint keyevent_state_to_awt_mods (GdkEvent *event);
struct item_event_hook_info
{
jobject peer_obj;
- jobject item_obj;
+ const char *label;
};
#endif /* __GTKPEER_H */
diff --git a/libjava/libltdl/ltdl.c b/libjava/libltdl/ltdl.c
index f691c8a439c..40ed84d417a 100644
--- a/libjava/libltdl/ltdl.c
+++ b/libjava/libltdl/ltdl.c
@@ -1584,13 +1584,7 @@ static struct lt_user_dlloader sys_dld = {
#if HAVE_MACH_O_DYLD_H
-# ifndef __private_extern__
-# define __private_extern__ extern
# include <mach-o/dyld.h>
-# undef __private_extern__
-# else
-# include <mach-o/dyld.h>
-# endif
#endif
#include <mach-o/getsect.h>
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 81d4b742d3b..a5becacb17b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,23 @@
+2003-12-30 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/13369
+ * include/bits/locale_facets.tcc (__verify_grouping):
+ Fix to deal properly with __grouping_tmp.size() >
+ __grouping.size().
+ * testsuite/22_locale/num_get/get/char/13.cc: New.
+ * testsuite/22_locale/num_get/get/wchar_t/13.cc: Ditto.
+
+2003-12-29 Jerry Quinn <jlquinn@optonline.net>
+
+ * include/bits/locale_facets.h (ctype.narrow,widen): Add cast.
+
+2003-12-29 Paolo Carlini <pcarlini@suse.de>
+
+ * acinclude.m4 (GLIBCXX_CHECK_LFS): Add -fno-exceptions
+ to CXXFLAGS.
+ * aclocal.m4: Regenerate.
+ * configure: Likewise.
+
2003-12-29 Mark Mitchell <mark@codesourcery.com>
* acconfig.h: Add _GLIBCXX_USE_C99_MATH.
@@ -26,6 +46,11 @@
* testsuite/27_io/objects/char/9.cc: Likewise.
* testsuite/ext/stdio_filebuf/char/10063-2.cc: Likewise.
+2003-12-28 Paolo Carlini <pcarlini@suse.de>
+
+ * include/ext/pool_allocator.h (class __pool_alloc): Use
+ operator new and operator delete.
+
2003-12-24 Mark Mitchell <mark@codesourcery.com>
* 27_io/basic_filebuf/close/char/4879.cc: Skip on newlib targets.
@@ -37,6 +62,14 @@
* 27_io/objects/char/7.cc: Likewise.
* 27_io/objects/char/9661-1.cc: Likewise.
+2003-12-24 Andrew Pinski <pinskia@physics.uc.edu>
+
+ * config/cpu/i386/atomicity.h (__exchange_and_add): Fix output
+ constraint.
+
+ PR libstdc++/13480
+ * config/cpu/i386/atomicity.h: Split up read-write memory operand.
+
2003-12-23 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/new_allocator.h (new_allocator): Proper allocator class.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index f4c449f5765..93bb23874a3 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -594,7 +594,9 @@ dnl Check whether LFS support is available.
dnl
AC_DEFUN(GLIBCXX_CHECK_LFS, [
AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
+ AC_LANG_CPLUSPLUS
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
AC_CACHE_VAL(glibcxx_cv_LFS, [
AC_TRY_LINK(
[#include <unistd.h>
@@ -611,7 +613,8 @@ AC_DEFUN(GLIBCXX_CHECK_LFS, [
if test $glibcxx_cv_LFS = yes; then
AC_DEFINE(_GLIBCXX_USE_LFS)
fi
- AC_LANG_RESTORE
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ AC_LANG_RESTORE
])
diff --git a/libstdc++-v3/aclocal.m4 b/libstdc++-v3/aclocal.m4
index a2fcf8af16b..6e00fe0070d 100644
--- a/libstdc++-v3/aclocal.m4
+++ b/libstdc++-v3/aclocal.m4
@@ -607,7 +607,9 @@ dnl Check whether LFS support is available.
dnl
AC_DEFUN(GLIBCXX_CHECK_LFS, [
AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
+ AC_LANG_CPLUSPLUS
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
AC_CACHE_VAL(glibcxx_cv_LFS, [
AC_TRY_LINK(
[#include <unistd.h>
@@ -624,7 +626,8 @@ AC_DEFUN(GLIBCXX_CHECK_LFS, [
if test $glibcxx_cv_LFS = yes; then
AC_DEFINE(_GLIBCXX_USE_LFS)
fi
- AC_LANG_RESTORE
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ AC_LANG_RESTORE
])
diff --git a/libstdc++-v3/config/cpu/i386/atomicity.h b/libstdc++-v3/config/cpu/i386/atomicity.h
index 70d38fe3269..7a949c30fa5 100644
--- a/libstdc++-v3/config/cpu/i386/atomicity.h
+++ b/libstdc++-v3/config/cpu/i386/atomicity.h
@@ -52,8 +52,9 @@ __exchange_and_add(volatile _Atomic_word* __mem, int __val)
/* obtain the atomic exchange/add spin lock */
do {
__asm__ __volatile__ ("xchg{l} {%0,%1|%1,%0}"
- : "+m" (__Atomicity_lock<0>::_S_atomicity_lock),
- "+r" (__tmp));
+ : "=m" (__Atomicity_lock<0>::_S_atomicity_lock),
+ "+r" (__tmp)
+ : "m" (__Atomicity_lock<0>::_S_atomicity_lock));
} while (__tmp);
__result = *__mem;
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 3d4909b7cac..2aaca2812dd 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -26707,6 +26707,8 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -fno-exceptions"
if test "${glibcxx_cv_LFS+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
@@ -26767,6 +26769,7 @@ fi
_ACEOF
fi
+ CXXFLAGS="$ac_save_CXXFLAGS"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 13e4ebbed7d..cb880917e55 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -35,7 +35,7 @@
#include <bits/os_defines.h>
// The current version of the C++ library in compressed ISO date format.
-#define __GLIBCXX__ 20031223
+#define __GLIBCXX__ 20031230
// Allow use of "export template." This is currently not a feature
// that g++ supports.
diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h
index eecb15c1b74..2d3f776b26f 100644
--- a/libstdc++-v3/include/bits/locale_facets.h
+++ b/libstdc++-v3/include/bits/locale_facets.h
@@ -878,7 +878,7 @@ namespace std
char_type
widen(char __c) const
{
- if (_M_widen_ok) return _M_widen[__c];
+ if (_M_widen_ok) return _M_widen[static_cast<unsigned char>(__c)];
this->_M_widen_init();
return this->do_widen(__c);
}
@@ -934,9 +934,10 @@ namespace std
char
narrow(char_type __c, char __dfault) const
{
- if (_M_narrow[__c]) return _M_narrow[__c];
+ if (_M_narrow[static_cast<unsigned char>(__c)])
+ return _M_narrow[static_cast<unsigned char>(__c)];
const char __t = do_narrow(__c, __dfault);
- if (__t != __dfault) _M_narrow[__c] = __t;
+ if (__t != __dfault) _M_narrow[static_cast<unsigned char>(__c)] = __t;
return __t;
}
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index 265c1437eba..40b612c1dde 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -2263,23 +2263,22 @@ namespace std
bool
__verify_grouping(const basic_string<_CharT>& __grouping,
const basic_string<_CharT>& __grouping_tmp)
- {
- size_t __i = 0;
- size_t __j = 0;
- const size_t __len = __grouping.size();
- const size_t __n = __grouping_tmp.size();
+ {
+ const size_t __n = __grouping_tmp.size() - 1;
+ const size_t __min = std::min(__n, __grouping.size() - 1);
+ size_t __i = __n;
bool __test = true;
-
+
// Parsed number groupings have to match the
// numpunct::grouping string exactly, starting at the
// right-most point of the parsed sequence of elements ...
- while (__test && __i < __n - 1)
- for (__j = 0; __test && __j < __len && __i < __n - 1; ++__j, ++__i)
- __test = __grouping[__j] == __grouping_tmp[__n - __i - 1];
+ for (size_t __j = 0; __j < __min && __test; --__i, ++__j)
+ __test = __grouping_tmp[__i] == __grouping[__j];
+ for (; __i && __test; --__i)
+ __test = __grouping_tmp[__i] == __grouping[__min];
// ... but the last parsed grouping can be <= numpunct
// grouping.
- __j == __len ? __j = 0 : __j;
- __test &= __grouping[__j] >= __grouping_tmp[__n - __i - 1];
+ __test &= __grouping_tmp[0] <= __grouping[__min];
return __test;
}
diff --git a/libstdc++-v3/include/c_std/std_cmath.h b/libstdc++-v3/include/c_std/std_cmath.h
index 8f22d5bd5ab..66866b2cc3a 100644
--- a/libstdc++-v3/include/c_std/std_cmath.h
+++ b/libstdc++-v3/include/c_std/std_cmath.h
@@ -436,7 +436,6 @@ namespace std
{ return __builtin_tanh(__x); }
}
-
#if _GLIBCXX_USE_C99_MATH
#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
// These are possible macros imported from C99-land. For strict
diff --git a/libstdc++-v3/include/ext/pool_allocator.h b/libstdc++-v3/include/ext/pool_allocator.h
index cb2df02997e..02303de31fd 100644
--- a/libstdc++-v3/include/ext/pool_allocator.h
+++ b/libstdc++-v3/include/ext/pool_allocator.h
@@ -200,7 +200,7 @@ namespace __gnu_cxx
((_Obj*)(void*)_S_start_free)->_M_free_list_link = *__free_list;
*__free_list = (_Obj*)(void*)_S_start_free;
}
- _S_start_free = new char[__bytes_to_get];
+ _S_start_free = static_cast<char*>(::operator new(__bytes_to_get));
if (_S_start_free == 0)
{
size_t __i;
@@ -225,7 +225,7 @@ namespace __gnu_cxx
}
}
_S_end_free = 0; // In case of exception.
- _S_start_free = new char[__bytes_to_get];
+ _S_start_free = static_cast<char*>(::operator new(__bytes_to_get));
// This should either throw an exception or remedy the situation.
// Thus we assume it succeeded.
}
@@ -290,7 +290,7 @@ namespace __gnu_cxx
}
if ((__n > (size_t) _S_max_bytes) || (_S_force_new > 0))
- __ret = new char[__n];
+ __ret = ::operator new(__n);
else
{
_Obj* volatile* __free_list = _S_free_list + _S_freelist_index(__n);
@@ -317,7 +317,7 @@ namespace __gnu_cxx
__pool_alloc<__threads, __inst>::deallocate(void* __p, size_t __n)
{
if ((__n > (size_t) _S_max_bytes) || (_S_force_new > 0))
- delete [] __p;
+ ::operator delete(__p);
else
{
_Obj* volatile* __free_list = _S_free_list + _S_freelist_index(__n);