From: aph Date: Wed, 15 Oct 2008 12:16:35 +0000 (+0000) Subject: 2008-10-14 Andrew Haley X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=958a71b8ff55307f590584359eea6da2bb1806db;p=thirdparty%2Fgcc.git 2008-10-14 Andrew Haley * constants.c (build_constant_data_ref): Make sure we only build one copy of the decl for the constant pool. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141133 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 0e59b21ae04c..d987bbe71b79 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2008-10-14 Andrew Haley + + * constants.c (build_constant_data_ref): Make sure we only build + one copy of the decl for the constant pool. + 2008-09-22 Andrew Haley * expr.c (rules): Add new rule for diff --git a/gcc/java/constants.c b/gcc/java/constants.c index 265557ec241d..526d9c777b54 100644 --- a/gcc/java/constants.c +++ b/gcc/java/constants.c @@ -448,21 +448,25 @@ build_constant_data_ref (bool indirect) } else { - tree type, decl; tree decl_name = mangled_classname ("_CD_", output_class); + tree decl = IDENTIFIER_GLOBAL_VALUE (decl_name); - /* Build a type with unspecified bounds. The will make sure - that targets do the right thing with whatever size we end - up with at the end. Using bounds that are too small risks - assuming the data is in the small data section. */ - type = build_array_type (ptr_type_node, NULL_TREE); - - /* We need to lay out the type ourselves, since build_array_type - thinks the type is incomplete. */ - layout_type (type); - - decl = build_decl (VAR_DECL, decl_name, type); - TREE_STATIC (decl) = 1; + if (! decl) + { + /* Build a type with unspecified bounds. The will make sure + that targets do the right thing with whatever size we end + up with at the end. Using bounds that are too small risks + assuming the data is in the small data section. */ + tree type = build_array_type (ptr_type_node, NULL_TREE); + + /* We need to lay out the type ourselves, since build_array_type + thinks the type is incomplete. */ + layout_type (type); + + decl = build_decl (VAR_DECL, decl_name, type); + TREE_STATIC (decl) = 1; + IDENTIFIER_GLOBAL_VALUE (decl_name) = decl; + } return decl; }