diff mbox

Emit default CASE_LABEL_EXPR for character CASE DEFAULT (PR fortran/40206)

Message ID 20100714230119.GM20208@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek July 14, 2010, 11:01 p.m. UTC
Hi!

This patch emits the default case (CASE_LABEL_EXPR with both low and high
NULL) for the default case if any.  Also, it doesn't emit all other
CASE_LABEL_EXPRs as case 1 ... 1:;, instead emits them as case 1:;.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2010-07-15  Jakub Jelinek  <jakub@redhat.com>

	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.


	Jakub
diff mbox

Patch

--- gcc/fortran/trans-stmt.c	2010-07-14 22:36:16.000000000 +0200
+++ gcc/fortran/trans-stmt.c	2010-07-14 22:21:29.000000000 +0200
@@ -1806,8 +1806,9 @@ 
         {
 	  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);
         }
 
--- gcc/testsuite/gfortran.dg/select_char_3.f90.jj	2010-07-14 22:40:59.000000000 +0200
+++ gcc/testsuite/gfortran.dg/select_char_3.f90	2010-07-14 22:33:33.000000000 +0200
@@ -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