re PR middle-end/21595 (__builtin_constant_p(&"Hello"[0]) is true for C but not for C++)
2005-05-17 Richard Guenther <rguenth@gcc.gnu.org> PR middle-end/21595 * builtins.c (fold_builtin_constant_p): Handle &"string cst"[0] as constant. * g++.dg/tree-ssa/builtin1.C: New testcase. From-SVN: r99825
This commit is contained in:
parent
64e6863ed5
commit
fb664a2cba
4 changed files with 31 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
2005-05-17 Richard Guenther <rguenth@gcc.gnu.org>
|
||||
|
||||
PR middle-end/21595
|
||||
* builtins.c (fold_builtin_constant_p): Handle
|
||||
&"string cst"[0] as constant.
|
||||
|
||||
2005-05-17 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* config/i386/sse.md (mulv16qi3, mulv2di3): New.
|
||||
|
|
|
@ -6338,10 +6338,17 @@ fold_builtin_constant_p (tree arglist)
|
|||
/* If we know this is a constant, emit the constant of one. */
|
||||
if (CONSTANT_CLASS_P (arglist)
|
||||
|| (TREE_CODE (arglist) == CONSTRUCTOR
|
||||
&& TREE_CONSTANT (arglist))
|
||||
|| (TREE_CODE (arglist) == ADDR_EXPR
|
||||
&& TREE_CODE (TREE_OPERAND (arglist, 0)) == STRING_CST))
|
||||
&& TREE_CONSTANT (arglist)))
|
||||
return integer_one_node;
|
||||
if (TREE_CODE (arglist) == ADDR_EXPR)
|
||||
{
|
||||
tree op = TREE_OPERAND (arglist, 0);
|
||||
if (TREE_CODE (op) == STRING_CST
|
||||
|| (TREE_CODE (op) == ARRAY_REF
|
||||
&& integer_zerop (TREE_OPERAND (op, 1))
|
||||
&& TREE_CODE (TREE_OPERAND (op, 0)) == STRING_CST))
|
||||
return integer_one_node;
|
||||
}
|
||||
|
||||
/* If this expression has side effects, show we don't know it to be a
|
||||
constant. Likewise if it's a pointer or aggregate type since in
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2005-05-17 Richard Guenther <rguenth@gcc.gnu.org>
|
||||
|
||||
PR middle-end/21595
|
||||
* g++.dg/tree-ssa/builtin1.C: New testcase.
|
||||
|
||||
2005-05-17 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/21454
|
||||
|
|
10
gcc/testsuite/g++.dg/tree-ssa/builtin1.C
Normal file
10
gcc/testsuite/g++.dg/tree-ssa/builtin1.C
Normal file
|
@ -0,0 +1,10 @@
|
|||
// { dg-do link }
|
||||
|
||||
extern void link_error();
|
||||
|
||||
int main()
|
||||
{
|
||||
if (! __builtin_constant_p (&"Hello"[0]))
|
||||
link_error();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue