Index: resolve.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/fortran/resolve.c,v retrieving revision 1.24 diff -u -r1.24 resolve.c --- resolve.c 15 Dec 2004 03:56:05 -0000 1.24 +++ resolve.c 17 Dec 2004 20:41:07 -0000 @@ -2713,7 +2713,8 @@ /* Check to see if an expression is suitable for use in a CASE statement. Makes sure that all case expressions are scalar - constants of the same type/kind. Return FAILURE if anything + constants of the same type. Only the CHARACTER type must have + the same kind as the case-expr. Return FAILURE if anything is wrong. */ static try @@ -2730,13 +2731,20 @@ return FAILURE; } - if (e->ts.kind != case_ts.kind) + /* C805 (R808) For a given case-construct, each case-value shall be of + the same type as case-expr. For character type, length differences + are allowed, but the kind type parameters shall be the same. */ + + if (case_ts.type == BT_CHARACTER && e->ts.kind != case_ts.kind) { gfc_error("Expression in CASE statement at %L must be kind %d", &e->where, case_ts.kind); return FAILURE; } + if (e->ts.kind != case_ts.kind) + gfc_convert_type (e, &case_ts, 2); + if (e->rank != 0) { gfc_error ("Expression in CASE statement at %L must be scalar",