diff options
author | Kai Tietz <ktietz@redhat.com> | 2011-10-14 21:30:42 +0200 |
---|---|---|
committer | Kai Tietz <ktietz@gcc.gnu.org> | 2011-10-14 21:30:42 +0200 |
commit | fc1f4caf5f6e1e616f5dbefcdb37bb661cd8b8fd (patch) | |
tree | 698b6ce8800d81c73e13932058f99a12e5693a1b | |
parent | 1c4153dd029bb2c325eb2232b123abf940537178 (diff) | |
download | gcc-fc1f4caf5f6e1e616f5dbefcdb37bb661cd8b8fd.zip gcc-fc1f4caf5f6e1e616f5dbefcdb37bb661cd8b8fd.tar.gz gcc-fc1f4caf5f6e1e616f5dbefcdb37bb661cd8b8fd.tar.bz2 |
gimplify.c (gimplify_expr): Take care that for bitwise-binary transformation the operands have compatible types.
* gimplify.c (gimplify_expr): Take care that for bitwise-binary
transformation the operands have compatible types.
* gfortran.fortran-torture/compile/logical-2.f90: New test.
From-SVN: r180006
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/gimplify.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.fortran-torture/compile/logical-2.f90 | 10 |
4 files changed, 34 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index da47071..ef5faf1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-10-14 Kai Tietz <ktietz@redhat.com> + + * gimplify.c (gimplify_expr): Take care that for bitwise-binary + transformation the operands have compatible types. + 2011-10-14 Jakub Jelinek <jakub@redhat.com> * config/i386/sse.md (vec_widen_smult_hi_v8hi, diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 2c9ba1d..8c2c5ac 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -7256,8 +7256,10 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, case TRUTH_XOR_EXPR: { tree orig_type = TREE_TYPE (*expr_p); + tree new_type, xop0, xop1; *expr_p = gimple_boolify (*expr_p); - if (!useless_type_conversion_p (orig_type, TREE_TYPE (*expr_p))) + new_type = TREE_TYPE (*expr_p); + if (!useless_type_conversion_p (orig_type, new_type)) { *expr_p = fold_convert_loc (input_location, orig_type, *expr_p); ret = GS_OK; @@ -7281,7 +7283,18 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, default: break; } - + /* Now make sure that operands have compatible type to + expression's new_type. */ + xop0 = TREE_OPERAND (*expr_p, 0); + xop1 = TREE_OPERAND (*expr_p, 1); + if (!useless_type_conversion_p (new_type, TREE_TYPE (xop0))) + TREE_OPERAND (*expr_p, 0) = fold_convert_loc (input_location, + new_type, + xop0); + if (!useless_type_conversion_p (new_type, TREE_TYPE (xop1))) + TREE_OPERAND (*expr_p, 1) = fold_convert_loc (input_location, + new_type, + xop1); /* Continue classified as tcc_binary. */ goto expr_2; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ca69717..f47bc70 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-10-14 Kai Tietz <ktietz@redhat.com> + + * gfortran.fortran-torture/compile/logical-2.f90: New test. + 2011-10-14 Jakub Jelinek <jakub@redhat.com> * gcc.target/i386/sse2-mul-1.c: New test. diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/logical-2.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/logical-2.f90 new file mode 100644 index 0000000..c31443f --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/logical-2.f90 @@ -0,0 +1,10 @@ +! Check for operand type validity after gimplification + +subroutine whatever() +logical(kind=1) :: l1 +logical(kind=2) :: l2 +logical(kind=4) :: l3 +if ((l1 .and. l2) .neqv. l3) then + l1 = .true. +endif +end |