From: Jeffrey Oldham Date: Thu, 28 Dec 2000 19:35:56 +0000 (+0000) Subject: varasm.c (initializer_constant_valid_p): Indicate subtraction of pointers to the... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=212addfac7f08b7cb1fbb223c2934f6addb77227;p=gcc.git varasm.c (initializer_constant_valid_p): Indicate subtraction of pointers to the same string constant is absolute. 2000-12-28 Jeffrey Oldham * varasm.c (initializer_constant_valid_p): Indicate subtraction of pointers to the same string constant is absolute. From-SVN: r38514 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e826e1cf91b..3230e138815 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2000-12-28 Jeffrey Oldham + + * varasm.c (initializer_constant_valid_p): Indicate subtraction of + pointers to the same string constant is absolute. + 2000-12-28 Joseph S. Myers * c-common.c (enum format_type): Add strfmon_format_type. diff --git a/gcc/varasm.c b/gcc/varasm.c index b2c283e13b7..8f76f45f719 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4252,6 +4252,14 @@ initializer_constant_valid_p (value, endtype) Then the value is absolute. */ if (valid0 == valid1 && valid0 != 0) return null_pointer_node; + + /* Since GCC guarantees that string constants are unique in the + generated code, a subtraction between two copies of the same + constant string is absolute. */ + if (valid0 && TREE_CODE (valid0) == STRING_CST && + valid1 && TREE_CODE (valid1) == STRING_CST && + TREE_STRING_POINTER (valid0) == TREE_STRING_POINTER (valid1)) + return null_pointer_node; } /* Support differences between labels. */