aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2002-02-26 22:08:57 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2002-02-26 22:08:57 +0100
commit6d73371a68e805956981592bdc2a631acaab2a33 (patch)
treeffe0e0f8a4d6f5960820d5d8fa900f3c93267c2f /gcc/dwarf2out.c
parent2d13abcf868ab46317b62f14702fa62c7948f212 (diff)
downloadgcc-6d73371a68e805956981592bdc2a631acaab2a33.zip
gcc-6d73371a68e805956981592bdc2a631acaab2a33.tar.gz
gcc-6d73371a68e805956981592bdc2a631acaab2a33.tar.bz2
re PR debug/5770 (undefined reference to `.LC0')
PR debug/5770 * dwarf2out.c (rtl_for_decl_location): Return CONST_STRING for STRING_CST initializer spanning the whole variable without embedded zeros. If expand_expr returned MEM, don't use it. * g++.dg/debug/debug4.C: New test. From-SVN: r50058
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index f4c298a..6c08939 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -8902,8 +8902,38 @@ rtl_for_decl_location (decl)
and will have been substituted directly into all expressions that use it.
C does not have such a concept, but C++ and other languages do. */
else if (TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl))
- rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
- EXPAND_INITIALIZER);
+ {
+ /* If a variable is initialized with a string constant without embedded
+ zeros, build CONST_STRING. */
+ if (TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
+ && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+ {
+ tree arrtype = TREE_TYPE (decl);
+ tree enttype = TREE_TYPE (arrtype);
+ tree domain = TYPE_DOMAIN (arrtype);
+ tree init = DECL_INITIAL (decl);
+ enum machine_mode mode = TYPE_MODE (enttype);
+
+ if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) == 1
+ && domain
+ && integer_zerop (TYPE_MIN_VALUE (domain))
+ && compare_tree_int (TYPE_MAX_VALUE (domain),
+ TREE_STRING_LENGTH (init) - 1) == 0
+ && ((size_t) TREE_STRING_LENGTH (init)
+ == strlen (TREE_STRING_POINTER (init)) + 1))
+ rtl = gen_rtx_CONST_STRING (VOIDmode, TREE_STRING_POINTER (init));
+ }
+
+ if (rtl == NULL)
+ {
+ rtl = expand_expr (DECL_INITIAL (decl), NULL_RTX, VOIDmode,
+ EXPAND_INITIALIZER);
+ /* If expand_expr returned a MEM, we cannot use it, since
+ it won't be output, leading to unresolved symbol. */
+ if (rtl && GET_CODE (rtl) == MEM)
+ rtl = NULL;
+ }
+ }
return rtl;
}