From: Jakub Jelinek Date: Thu, 15 Jul 2010 07:52:51 +0000 (+0200) Subject: re PR fortran/40206 ([gfortran] Incorrect warning with -Wuninitialized) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=79c743005119639f4d30b82a708613a072e26681;p=gcc.git re PR fortran/40206 ([gfortran] Incorrect warning with -Wuninitialized) PR fortran/40206 * trans-stmt.c (gfc_trans_character_select): Always use NULL for high in CASE_LABEL_EXPR and use NULL for low for the default case. * gfortran.dg/select_char_3.f90: New test. From-SVN: r162209 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ea1a501b497..8d89661e668 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -11,6 +11,10 @@ or NE_EXPR and one of the strings is string literal with LEN_TRIM bigger than the length of the other string, they compare unequal. + PR fortran/40206 + * trans-stmt.c (gfc_trans_character_select): Always use NULL for high + in CASE_LABEL_EXPR and use NULL for low for the default case. + 2010-07-14 Mikael Morin * trans-array.c (gfc_conv_section_upper_bound): Remove diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 8bd0f91517f..cc3dd7297ba 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -1681,8 +1681,9 @@ gfc_trans_character_select (gfc_code *code) { label = gfc_build_label_decl (NULL_TREE); tmp = fold_build3 (CASE_LABEL_EXPR, void_type_node, - build_int_cst (NULL_TREE, d->n), - build_int_cst (NULL_TREE, d->n), label); + (d->low == NULL && d->high == NULL) + ? NULL : build_int_cst (NULL_TREE, d->n), + NULL, label); gfc_add_expr_to_block (&body, tmp); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3e04816dda3..bb7b4b0bfc7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-15 Jakub Jelinek + + PR fortran/40206 + * gfortran.dg/select_char_3.f90: New test. + 2010-07-15 Magnus Granberg Kevin F. Quinn diff --git a/gcc/testsuite/gfortran.dg/select_char_3.f90 b/gcc/testsuite/gfortran.dg/select_char_3.f90 new file mode 100644 index 00000000000..f0a7c874175 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_char_3.f90 @@ -0,0 +1,15 @@ +! PR fortran/40206 +! { dg-do compile } +! { dg-options "-O2 -Wuninitialized" } + +function char2type (char) + character, intent(in) :: char + integer :: char2type + + select case (char) + case ('E','e') + char2type=1 + case default + char2type=-1234 + end select +end function