diff options
author | Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de> | 2004-06-15 23:50:50 +0200 |
---|---|---|
committer | Tobias Schlüter <tobi@gcc.gnu.org> | 2004-06-15 23:50:50 +0200 |
commit | 6ef4215401ab8001886973790886dfd75446c037 (patch) | |
tree | 91cec34fb614da23cba18dd77a187546799cb659 | |
parent | 0173bb6f2d715c4c3839c17e26a38bd522e07fa4 (diff) | |
download | gcc-6ef4215401ab8001886973790886dfd75446c037.zip gcc-6ef4215401ab8001886973790886dfd75446c037.tar.gz gcc-6ef4215401ab8001886973790886dfd75446c037.tar.bz2 |
re PR fortran/15962 (constant expression not recognized as such)
fortran/
PR fortran/15962
* match.c (match_case_selector): Call gfc_match_init_expr
instead of gfc_match_expr.
* resolve.c (validate_case_label_expr): No need to check for
constant, since it wouldn't have been matched with the fix to
match.c.
testsuite/
PR fortran/15962
* gfortran.fortran-torture/execute/select_1.f90: New test.
From-SVN: r83202
-rw-r--r-- | gcc/fortran/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fortran/match.c | 8 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.fortran-torture/execute/select_1.f90 | 17 | ||||
-rw-r--r-- | gcc/testsuite/lib/f-torture.exp | 130 |
6 files changed, 36 insertions, 140 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 57a9164..ef5d72b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2004-06-15 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> + + PR fortran/15962 + * match.c (match_case_selector): Call gfc_match_init_expr + instead of gfc_match_expr. + * resolve.c (validate_case_label_expr): No need to check for + constant, since it wouldn't have been matched with the fix to + match.c. + 2004-06-14 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> PR fortran/15211 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 79a7e4c..bc2379d 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -3102,7 +3102,7 @@ match_case_selector (gfc_case ** cp) if (gfc_match_char (':') == MATCH_YES) { - m = gfc_match_expr (&c->high); + m = gfc_match_init_expr (&c->high); if (m == MATCH_NO) goto need_expr; if (m == MATCH_ERROR) @@ -3111,7 +3111,7 @@ match_case_selector (gfc_case ** cp) else { - m = gfc_match_expr (&c->low); + m = gfc_match_init_expr (&c->low); if (m == MATCH_ERROR) goto cleanup; if (m == MATCH_NO) @@ -3123,7 +3123,7 @@ match_case_selector (gfc_case ** cp) c->high = c->low; else { - m = gfc_match_expr (&c->high); + m = gfc_match_init_expr (&c->high); if (m == MATCH_ERROR) goto cleanup; /* MATCH_NO is fine. It's OK if nothing is there! */ @@ -3134,7 +3134,7 @@ match_case_selector (gfc_case ** cp) return MATCH_YES; need_expr: - gfc_error ("Expected expression in CASE at %C"); + gfc_error ("Expected initialization expression in CASE at %C"); cleanup: free_case (c); diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index d33dcb2..b19721f 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -2586,13 +2586,6 @@ validate_case_label_expr (gfc_expr * e, gfc_expr * case_expr) if (e == NULL) return SUCCESS; - if (e->expr_type != EXPR_CONSTANT) - { - gfc_error ("Expression in CASE statement at %L must be a constant", - &e->where); - return FAILURE; - } - if (e->ts.type != case_ts.type) { gfc_error ("Expression in CASE statement at %L must be of type %s", diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dc1100d..2d74fb6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-06-15 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> + + PR fortran/15962 + * gfortran.fortran-torture/execute/select_1.f90: New test. + 2004-06-15 Paul Brook <paul@codesourcery.com> * gcc.dg/arm-mmx-1.c: Use asm to clobber registers. diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/select_1.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/select_1.f90 new file mode 100644 index 0000000..b6ed5be --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/execute/select_1.f90 @@ -0,0 +1,17 @@ +! from PR 15962, we used to require constant expressions instead of +! initialization expressions in case-statements +function x(k) +integer :: k +integer :: x +integer, parameter :: i(2) = (/1,2/) + +select case(k) +case (1:size(i)) + x = i(k) +case default + x = 0 +end select +end function + +if (x(2).NE.2 .OR. x(11).NE.0) call abort() +end diff --git a/gcc/testsuite/lib/f-torture.exp b/gcc/testsuite/lib/f-torture.exp index 88e8773..61ff485 100644 --- a/gcc/testsuite/lib/f-torture.exp +++ b/gcc/testsuite/lib/f-torture.exp @@ -124,135 +124,7 @@ proc f-torture-compile { src option } { # # f-torture-execute -- utility to compile and execute a testcase # -# SRC is the full pathname of the testcase. -# -# If the testcase has an associated .x file, we source that to run the -# test instead. We use .x so that we don't lengthen the existing filename -# to more than 14 chars. -# -proc f-torture-execute { src } { - global tmpdir tool srcdir output compiler_conditional_xfail_data - - # Check for alternate driver. - if [file exists [file rootname $src].x] { - verbose "Using alternate driver [file rootname [file tail $src]].x" 2 - set done_p 0 - catch "set done_p \[source [file rootname $src].x\]" - if { $done_p } { - return - } - } - - # Look for a loop within the source code - if we don't find one, - # don't pass -funroll[-all]-loops. - global torture_with_loops torture_without_loops - if [expr [search_for_re $src "do *\[0-9\]"]+[search_for_re $src "end *do"]] then { - set option_list $torture_with_loops - } else { - set option_list $torture_without_loops - } - - set executable $tmpdir/[file tail [file rootname $src].x] - - regsub "^$srcdir/?" $src "" testcase - # If we couldn't rip $srcdir out of `src' then just do the best we can. - # The point is to reduce the unnecessary noise in the logs. Don't strip - # out too much because different testcases with the same name can confuse - # `test-tool'. - if [string match "/*" $testcase] { - set testcase "[file tail [file dirname $src]]/[file tail $src]" - } - - foreach option $option_list { - # torture_{compile,execute}_xfail are set by the .x script - # (if present) - if [info exists torture_compile_xfail] { - setup_xfail $torture_compile_xfail - } - - # torture_execute_before_{compile,execute} can be set by the .x script - # (if present) - if [info exists torture_eval_before_compile] { - set ignore_me [eval $torture_eval_before_compile] - } - - remote_file build delete $executable - verbose "Testing $testcase, $option" 1 - - set options "" - lappend options "additional_flags=-w $option" - set comp_output [g77_target_compile "$src" "$executable" executable $options]; - - # Set a few common compiler messages. - set fatal_signal "*77*: Internal compiler error: program*got fatal signal" - - if [string match "$fatal_signal 6" $comp_output] then { - g77_fail $testcase "Got Signal 6, $option" - remote_file build delete $executable - continue - } - - if [string match "$fatal_signal 11" $comp_output] then { - g77_fail $testcase "Got Signal 11, $option" - remote_file build delete $executable - continue - } - - # We shouldn't get these because of -w, but just in case. - if [string match "*77*:*warning:*" $comp_output] then { - warning "$testcase: (with warnings) $option" - send_log "$comp_output\n" - unresolved "$testcase, $option" - remote_file build delete $executable - continue - } - - set comp_output [prune_warnings $comp_output] - - set unsupported_message [g77_check_unsupported_p $comp_output] - - if { $unsupported_message != "" } { - unsupported "$testcase: $unsupported_message" - continue - } elseif ![file exists $executable] { - if ![is3way] { - fail "$testcase compilation, $option" - untested "$testcase execution, $option" - continue - } else { - # FIXME: since we can't test for the existance of a remote - # file without short of doing an remote file list, we assume - # that since we got no output, it must have compiled. - pass "$testcase compilation, $option" - } - } else { - pass "$testcase compilation, $option" - } - - # See if this source file uses "long long" types, if it does, and - # no_long_long is set, skip execution of the test. - if [target_info exists no_long_long] then { - if [expr [search_for_re $src "integer\*8"]] then { - untested "$testcase execution, $option" - continue - } - } - - if [info exists torture_execute_xfail] { - setup_xfail $torture_execute_xfail - } - - if [info exists torture_eval_before_execute] { - set ignore_me [eval $torture_eval_before_execute] - } - - set result [g77_load "$executable" "" ""] - set status [lindex $result 0]; - set output [lindex $result 1]; - if { $status == "pass" } { - remote_file build delete $executable - } - $status "$testcase execution, $option" +# SRC is the full pathname of the } } |