builtins.c (get_pointer_alignment, [...]): Use POINTER_TYPE_P instead TREE_CODE checking against POINTER_TYPE.

* builtins.c (get_pointer_alignment, gimplify_va_arg_expr,
	expand_builtin_printf, expand_builtin_fprintf,
	expand_builtin_sprintf): Use POINTER_TYPE_P instead TREE_CODE
	checking against POINTER_TYPE.
	(validate_arglist): Handle POINTER_TYPE code by checking
	POINTER_TYPE_P.
	* g++.dg/tree-ssa/empty-1.C: New test.

From-SVN: r94147
This commit is contained in:
Jakub Jelinek 2005-01-24 09:59:28 +01:00 committed by Jakub Jelinek
parent cf94b0fccc
commit 7b92212279
4 changed files with 43 additions and 13 deletions

View File

@ -1,3 +1,12 @@
2005-01-24 Jakub Jelinek <jakub@redhat.com>
* builtins.c (get_pointer_alignment, gimplify_va_arg_expr,
expand_builtin_printf, expand_builtin_fprintf,
expand_builtin_sprintf): Use POINTER_TYPE_P instead TREE_CODE
checking against POINTER_TYPE.
(validate_arglist): Handle POINTER_TYPE code by checking
POINTER_TYPE_P.
2005-01-24 Paolo Bonzini <bonzini@gnu.org>
* rtlanal.c (non_rtx_starting_operands, for_each_rtx_1,

View File

@ -201,7 +201,7 @@ get_pointer_alignment (tree exp, unsigned int max_align)
{
unsigned int align, inner;
if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
if (! POINTER_TYPE_P (TREE_TYPE (exp)))
return 0;
align = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
@ -215,7 +215,7 @@ get_pointer_alignment (tree exp, unsigned int max_align)
case CONVERT_EXPR:
case NON_LVALUE_EXPR:
exp = TREE_OPERAND (exp, 0);
if (TREE_CODE (TREE_TYPE (exp)) != POINTER_TYPE)
if (! POINTER_TYPE_P (TREE_TYPE (exp)))
return align;
inner = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (exp)));
@ -3988,7 +3988,7 @@ gimplify_va_arg_expr (tree *expr_p, tree *pre_p, tree *post_p)
In that case, unwrap both types so that we can compare the
underlying records. */
if (TREE_CODE (have_va_type) == ARRAY_TYPE
|| TREE_CODE (have_va_type) == POINTER_TYPE)
|| POINTER_TYPE_P (have_va_type))
{
want_va_type = TREE_TYPE (want_va_type);
have_va_type = TREE_TYPE (have_va_type);
@ -4486,7 +4486,7 @@ expand_builtin_printf (tree arglist, rtx target, enum machine_mode mode,
if (! arglist)
return 0;
fmt = TREE_VALUE (arglist);
if (TREE_CODE (TREE_TYPE (fmt)) != POINTER_TYPE)
if (! POINTER_TYPE_P (TREE_TYPE (fmt)))
return 0;
arglist = TREE_CHAIN (arglist);
@ -4499,7 +4499,7 @@ expand_builtin_printf (tree arglist, rtx target, enum machine_mode mode,
if (strcmp (fmt_str, "%s\n") == 0)
{
if (! arglist
|| TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
|| ! POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (arglist)))
|| TREE_CHAIN (arglist))
return 0;
fn = fn_puts;
@ -4588,13 +4588,13 @@ expand_builtin_fprintf (tree arglist, rtx target, enum machine_mode mode,
if (! arglist)
return 0;
fp = TREE_VALUE (arglist);
if (TREE_CODE (TREE_TYPE (fp)) != POINTER_TYPE)
if (! POINTER_TYPE_P (TREE_TYPE (fp)))
return 0;
arglist = TREE_CHAIN (arglist);
if (! arglist)
return 0;
fmt = TREE_VALUE (arglist);
if (TREE_CODE (TREE_TYPE (fmt)) != POINTER_TYPE)
if (! POINTER_TYPE_P (TREE_TYPE (fmt)))
return 0;
arglist = TREE_CHAIN (arglist);
@ -4607,7 +4607,7 @@ expand_builtin_fprintf (tree arglist, rtx target, enum machine_mode mode,
if (strcmp (fmt_str, "%s") == 0)
{
if (! arglist
|| TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE
|| ! POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (arglist)))
|| TREE_CHAIN (arglist))
return 0;
arg = TREE_VALUE (arglist);
@ -4675,13 +4675,13 @@ expand_builtin_sprintf (tree arglist, rtx target, enum machine_mode mode)
if (! arglist)
return 0;
dest = TREE_VALUE (arglist);
if (TREE_CODE (TREE_TYPE (dest)) != POINTER_TYPE)
if (! POINTER_TYPE_P (TREE_TYPE (dest)))
return 0;
arglist = TREE_CHAIN (arglist);
if (! arglist)
return 0;
fmt = TREE_VALUE (arglist);
if (TREE_CODE (TREE_TYPE (fmt)) != POINTER_TYPE)
if (! POINTER_TYPE_P (TREE_TYPE (fmt)))
return 0;
arglist = TREE_CHAIN (arglist);
@ -4717,7 +4717,7 @@ expand_builtin_sprintf (tree arglist, rtx target, enum machine_mode mode)
if (! arglist || TREE_CHAIN (arglist))
return 0;
arg = TREE_VALUE (arglist);
if (TREE_CODE (TREE_TYPE (arg)) != POINTER_TYPE)
if (! POINTER_TYPE_P (TREE_TYPE (arg)))
return 0;
if (target != const0_rtx)
@ -8058,8 +8058,14 @@ validate_arglist (tree arglist, ...)
/* If no parameters remain or the parameter's code does not
match the specified code, return false. Otherwise continue
checking any remaining arguments. */
if (arglist == 0
|| code != TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))))
if (arglist == 0)
goto end;
if (code == POINTER_TYPE)
{
if (! POINTER_TYPE_P (TREE_TYPE (TREE_VALUE (arglist))))
goto end;
}
else if (code != TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))))
goto end;
break;
}

View File

@ -1,5 +1,7 @@
2005-01-24 Jakub Jelinek <jakub@redhat.com>
* g++.dg/tree-ssa/empty-1.C: New test.
PR middle-end/19551
* gcc.c-torture/execute/20050121-1.c: New test.
* gcc.dg/20050121-2.c: New test.

View File

@ -0,0 +1,13 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
struct S {};
S bar (const S &a)
{
S s;
s = a;
return s;
}
/* Test whether memcpy call has been optimized out. */
/* { dg-final { scan-tree-dump-times "memcpy" 0 "optimized"} } */