summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/varasm.c8
2 files changed, 13 insertions, 0 deletions
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 <oldham@codesourcery.com>
+
+ * varasm.c (initializer_constant_valid_p): Indicate subtraction of
+ pointers to the same string constant is absolute.
+
2000-12-28 Joseph S. Myers <jsm28@cam.ac.uk>
* 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. */