With the proposed patch
2 | if (.TRUE.)
| 1
Error: Cannot assign to a named constant at (1)
3 | else if (.FALSE.)
| 1
Error: Unexpected junk after ELSE statement at (1)
is changed to
2 | if (.TRUE.)
| 1
Error: Syntax error in IF-clause after (1)
3 | else if (.FALSE.)
| 1
Error: Missing THEN in ELSE IF statement after (1)
The first change is done by removing the block
/* The gfc_match_assignment() above may have returned a MATCH_NO
…
return MATCH_ERROR;
}
This block has been introduced at revision r116570 to handle assignment to a
named constant as in the test
simpleif_2.f90, but this is now handled elsewhere.
The second change is done by some more parsing of the ELSE IF statement.
While at these changes, I have also made the error
3 | if (.FALSE. then c="!"
| 1
Error: Missing ')' in statement at or before (1)
to be less surprising
3 | if (.FALSE. then c="!"
| 1
Error: Missing ')' in statement at or before (1)
Also
7 | if a=b !
| 1
Error: Unclassifiable statement at (1)
changed to
7 | if a=b !
| 1
Error: Missing '(' in IF-expression at (1)
which avoids the error to be deleted if it appears after other ones.
Bootstrapped and tested on darwin. Is it OK for trunk?
TIA
Dominique
2019-03-17 Dominique d'Humieres <[email protected]>
PR fortran/60144
* match.c (gfc_match_parens): Change the location for missing ')'.
(gfc_match_if): Detect a missing '('. Remove the spurious named
constant error. Change the wording of some errors.
(gfc_match_else): Change the wording of an error.
(gfc_match_elseif): Detect a missing '('. Improve the matching
process to get a better syntax analysis.
2019-03-17 Dominique d'Humieres <[email protected]>
PR fortran/60144
* gfortran.dg/block_name_2.f90: Adjust dg-error.
* gfortran.dg/dec_type_print_3.f90.f90: Likewise
* gfortran.dg/pr60144.f90: New test.
patch-60144
Description: Binary data
