From: Jakub Jelinek Date: Mon, 24 Jan 2005 08:59:28 +0000 (+0100) Subject: builtins.c (get_pointer_alignment, [...]): Use POINTER_TYPE_P instead TREE_CODE check... X-Git-Tag: releases/gcc-4.0.0~1323 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7b9221227970e08c1457c10a2b76314d0746b9bf;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 874eccdca0c4..c176b017e329 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2005-01-24 Jakub Jelinek + + * 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 * rtlanal.c (non_rtx_starting_operands, for_each_rtx_1, diff --git a/gcc/builtins.c b/gcc/builtins.c index a13ecef5f656..78076db2bf28 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b64036b9f708..d1bde8aa50d1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2005-01-24 Jakub Jelinek + * 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. diff --git a/gcc/testsuite/g++.dg/tree-ssa/empty-1.C b/gcc/testsuite/g++.dg/tree-ssa/empty-1.C new file mode 100644 index 000000000000..f7c8ecc14bf9 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/empty-1.C @@ -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"} } */