[Bug fortran/60144] Misleading error message when missing "then" after "if" and "else if"
dominiq at lps dot ens.fr
gcc-bugzilla@gcc.gnu.org
Sat Feb 2 19:32:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60144
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |WAITING
--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Error messages:
> ----------------------
> if.F90:2.15:
>
> if (.TRUE.)
> 1
> Error: Cannot assign to a named constant at (1)
> if.F90:3.11:
>
> else if (.FALSE.)
> 1
> Error: Unexpected junk after ELSE statement at (1)
> [...]
> ----------------------
>
> Both errors should read something like "Missing THEN after IF/ELSE IF".
>
> The first error message doesn't even make sense...
% gfc dec_type_print_red.f90
dec_type_print_red.f90:20:11:
20 | if (b) type*,a(i) ! test TYPE as PRINT inside one-line IF
| 1
Error: Cannot assign to a named constant at (1)
(from gfortran.dg/dec_type_print.f90 compiled without the -fdec option).
IMO replacing "Cannot assign to a named constant" with "Syntax error" will give
an immediate clue of what is wrong. A longer alternative could be something
such as
""Syntax error, missing or bad STATEMENT".
More information about the Gcc-bugs
mailing list