Commit fb664a2c by Richard Guenther Committed by Richard Biener

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
parent 64e6863e
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
......
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
......
// { dg-do link }
extern void link_error();
int main()
{
if (! __builtin_constant_p (&"Hello"[0]))
link_error();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment