Example: ...testsuite/gfortran.dg> gfortran -c -pedantic-errors c_by_val_4.f ; echo $? c_by_val_4.f:14.22: CALL DOIT( %VAL( P ) ) ! { dg-warning "Extension: argument list fu 1 Warnung: Extension: argument list function at (1) c_by_val_4.f:16.22: CALL DOIT( %VAL( P ) ) ! { dg-warning "Extension: argument list fu 1 Warnung: Extension: argument list function at (1) 0 Expected: - Non-zero exit code - "Error:" instead of "Warning:" Have fun when fixing this as several "dg-do run" tests have -pedantic warnings, -no-pedantic does not exist, and dg.exp contains: set DEFAULT_FFLAGS " -pedantic-errors"
The same is true for -Werror. Warnings still give an exit status code of zero.
> The same is true for -Werror. I have to correct myself: -Werror gives a non-zero exit status, but still writes "Warning:". I think gfortran should follow gcc by changing also the label from "Warning:" to "Error:" for -Werror. -pedantic-errors seems to be difficult as it is hard to divide -Wall warnings from -pedantic warnings. The easiest way is probably to imply -Wall by -pedantic_errors (defined in flags.h as flag_pedantic_errors).
I am not sure if gfortran diagnostics are different, but... are you sure that particular warning is a pedantic warning and not simply an unconditional warning? AFAIK, pedantic-errors will turn only pedantic warnings into errors, other warnings will still be warnings unless -Werror.
> I am not sure if gfortran diagnostics are different, I think gfortran handles the warnings quite different, not that I know much about the details of the C frontend. > but... are you sure that particular warning is a pedantic warning and not > simply an unconditional warning? primary.c: if (x_hex && pedantic primary.c- && (gfc_notify_std (GFC_STD_GNU, "Extension: Hexadecimal " This gives only an error with pedantic set (and -std=f95 or -std=f2003). Otherwise, -pedantic is quite interwoven with the rest: options.c, e.g.: if (pedantic) { gfc_option.warn_ampersand = 1; gfc_option.warn_tabs = 0; } No idea how to untangle -pedantic from -Wtabs or -Wampersand if -pedantic-errors has been given, but -Werror has not. Silently accepting and ignoring it, seems not to be the right way. The simple solution is not to accept -pedantic-errors (and to point to -Werror) or to turn on -Werror for -pedantic-errors. Both are rather easy solutions - and feel a bit clumsy. It needs presumably quite a lot of work to support -pedantic-errors properly. First and simpler step should be to change "Warning:" into "Error:" for -Werror to be in line with the C front end.
(In reply to comment #4) > > I am not sure if gfortran diagnostics are different, > > I think gfortran handles the warnings quite different, not that I know much > about the details of the C frontend. > Ah, OK. Then forget anything that I said.
(In reply to comment #4) > > No idea how to untangle -pedantic from -Wtabs or -Wampersand if > -pedantic-errors has been given, but -Werror has not. > What gfortran should do is that if pedantic enables Wtabs, then the warnings should be of the form: if (pedantic && warn_tabs) pedantic("whatever"); else if (warn_tabs) warning("whatever"); pedantic() emits errors if -pedantic-errors, otherwise it emits warnings. warning() emits errors if -Werror, otherwise it emits warnings. I guess there would be similar functions in gfortran. (It would be great to integrate the diagnostics machinery but making things work in a similar way is already a step forward).
An update given the new diagnostics machinery: * -Werror works as expected (comment #2) * -pedantic-errors (-Werror=pedantic) should give errors for anything marked with -Wpedantic such as: gfc_warning (OPT_Wpedantic, "Extension: backslash character at %C"); However, Fortran does not seem to use OPT_Wpedantic. You could use LangEnabledBy to enable with it whatever option you wish.
The following patch produces the desired error for the example of comment #0: --- gcc/fortran/primary.c (revision 232904) +++ gcc/fortran/primary.c (working copy) @@ -1698,7 +1698,9 @@ } } - if (!gfc_notify_std (GFC_STD_GNU, "argument list function at %C")) + if (!gfc_notify_std (GFC_STD_GNU, "argument list function at %C") || + (pedantic && + !gfc_warning (OPT_Wpedantic, "Extension: argument list function at %C"))) { m = MATCH_ERROR; goto cleanup; % gfc-trunk -c -Werror=pedantic gcc/testsuite/gfortran.dg/c_by_val_4.f gcc/testsuite/gfortran.dg/c_by_val_4.f:14:22: CALL DOIT( %VAL( P ) ) ! { dg-warning "Extension: argument list function" } 1 Error: Extension: argument list function at (1) [-Werror=pedantic] gcc/testsuite/gfortran.dg/c_by_val_4.f:16:22: CALL DOIT( %VAL( P ) ) ! { dg-warning "Extension: argument list function" } 1 Error: Extension: argument list function at (1) [-Werror=pedantic] A more general solution might be to extend gfc_notify_std to generally handle extensions.
Since at least 4.8 '-pedantic -Werror' gives an error; % gfortran /opt/gcc/work/gcc/testsuite/gfortran.dg/c_by_val_4.f -c -pedantic -Werror /opt/gcc/work/gcc/testsuite/gfortran.dg/c_by_val_4.f:14:6: CALL DOIT( %VAL( P ) ) ! { dg-warning "Extension: argument list function" } 1 Error: Unclassifiable statement at (1) /opt/gcc/work/gcc/testsuite/gfortran.dg/c_by_val_4.f:16:6: CALL DOIT( %VAL( P ) ) ! { dg-warning "Extension: argument list function" } 1 Error: Unclassifiable statement at (1) but '-pedantic-errors' does not % gfortran /opt/gcc/work/gcc/testsuite/gfortran.dg/c_by_val_4.f -c -pedantic-errors /opt/gcc/work/gcc/testsuite/gfortran.dg/c_by_val_4.f:14:22: CALL DOIT( %VAL( P ) ) ! { dg-warning "Extension: argument list function" } 1 Warning: GNU Extension: argument list function at (1) /opt/gcc/work/gcc/testsuite/gfortran.dg/c_by_val_4.f:16:22: CALL DOIT( %VAL( P ) ) ! { dg-warning "Extension: argument list function" } 1 Warning: GNU Extension: argument list function at (1) AFAICT '-pedantic-errors' is not handled by the gfortran FE. Note that '-pedantic' may change a warning to an error: % gfortran /opt/gcc/work/gcc/testsuite/gfortran.dg/hollerith8.f90 -pedantic /opt/gcc/work/gcc/testsuite/gfortran.dg/hollerith8.f90:6:17: call wrtout (9hHELLO YOU, 9) 1 Warning: Legacy Extension: Hollerith constant at (1) /opt/gcc/work/gcc/testsuite/gfortran.dg/hollerith8.f90:6:15: call wrtout (9hHELLO YOU, 9) 1 Error: Rank mismatch in argument 'iarray' at (1) (rank-1 and scalar)