diff options
author | Jason Merrill <jason@redhat.com> | 2009-02-23 16:23:58 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-02-23 16:23:58 -0500 |
commit | d8028f2cc34c6fe1f5a8b93762195dcdbbd37b71 (patch) | |
tree | 2f9fbf6ee094e40be52158fbd7313e4dbd65c998 /gcc/varasm.c | |
parent | 68c512f66db07a1bbe7f1fb9c42eedeba65e13c2 (diff) | |
download | gcc-d8028f2cc34c6fe1f5a8b93762195dcdbbd37b71.zip gcc-d8028f2cc34c6fe1f5a8b93762195dcdbbd37b71.tar.gz gcc-d8028f2cc34c6fe1f5a8b93762195dcdbbd37b71.tar.bz2 |
re PR c++/38880 (g++.dg/init/const7.C XFAILed)
PR c++/38880
* varasm.c (initializer_constant_valid_p) [PLUS_EXPR]: Check
narrowing_initializer_constant_valid_p.
(narrowing_initializer_constant_valid_p): Don't return
null_pointer_node for adding a pointer to itself.
From-SVN: r144395
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index 0589fc9..c724fcd 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4070,8 +4070,8 @@ constructor_static_from_elts_p (const_tree ctor) && !VEC_empty (constructor_elt, CONSTRUCTOR_ELTS (ctor))); } -/* A subroutine of initializer_constant_valid_p. VALUE is either a - MINUS_EXPR or a POINTER_PLUS_EXPR. This looks for cases of VALUE +/* A subroutine of initializer_constant_valid_p. VALUE is a MINUS_EXPR, + PLUS_EXPR or POINTER_PLUS_EXPR. This looks for cases of VALUE which are valid when ENDTYPE is an integer of any size; in particular, this does not accept a pointer minus a constant. This returns null_pointer_node if the VALUE is an absolute constant @@ -4124,7 +4124,9 @@ narrowing_initializer_constant_valid_p (tree value, tree endtype) /* Both initializers must be known. */ if (op0 && op1) { - if (op0 == op1) + if (op0 == op1 + && (op0 == null_pointer_node + || TREE_CODE (value) == MINUS_EXPR)) return null_pointer_node; /* Support differences between labels. */ @@ -4315,12 +4317,10 @@ initializer_constant_valid_p (tree value, tree endtype) } /* Support narrowing pointer differences. */ - if (TREE_CODE (value) == POINTER_PLUS_EXPR) - { - ret = narrowing_initializer_constant_valid_p (value, endtype); - if (ret != NULL_TREE) - return ret; - } + ret = narrowing_initializer_constant_valid_p (value, endtype); + if (ret != NULL_TREE) + return ret; + break; case MINUS_EXPR: |