[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 janus at gcc dot gnu.org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED Target Milestone|--- |7.0 --- Comment #16 from janus at gcc dot gnu.org --- r241870 fixes this issue. Closing.
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #15 from janus at gcc dot gnu.org --- Author: janus Date: Sat Nov 5 10:35:23 2016 New Revision: 241870 URL: https://gcc.gnu.org/viewcvs?rev=241870=gcc=rev Log: 2016-11-05 Janus WeilManuel Lopez-Ibanez PR fortran/69495 * invoke.texi: Mention -Wpedantic as an alias of -pedantic. * check.c (gfc_check_transfer): Mention responsible flag in warning message. * frontend-passes.c (do_warn_function_elimination): Ditto. * resolve.c (resolve_elemental_actual): Ditto. (resolve_operator): Ditto. (warn_unused_fortran_label): Ditto. * trans-common.c (translate_common): Ditto. 2016-11-05 Janus Weil Dominique d'Humieres PR fortran/69495 * gfortran.dg/elemental_optional_args_6.f90: Use -Wpedantic flag. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/check.c trunk/gcc/fortran/frontend-passes.c trunk/gcc/fortran/invoke.texi trunk/gcc/fortran/resolve.c trunk/gcc/fortran/trans-common.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/elemental_optional_args_6.f90
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #14 from janus at gcc dot gnu.org --- (In reply to Manuel López-Ibáñez from comment #13) > (In reply to Dominique d'Humieres from comment #11) > > I think you need to add a line > > > > ! { dg-options "-pedantic" } > > > > to elemental_optional_args_6.f90 (untested). > > I'd suggest to use -Wpedantic, since this is the "modern" name Thanks for the clarifications to both of you. Indeed that addition does the trick, and I agree that -Wpedantic should be preferred. However, I noticed that -Wpedantic is not documented at all in the gfortran manual (see https://gcc.gnu.org/onlinedocs/gfortran/Error-and-Warning-Options.html#Error-and-Warning-Options). Only -pedantic is mentioned. The (non-Fortran) GCC documentation properly shows both forms.
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #10 from Dominique d'Humieres --- > Created attachment 37527 [details] > patch > > The attached patch should take care of all cases mentioned above. > > Unfortunately it causes a testsuite failure of elemental_optional_args_6.f90 > and I just cannot understand why :( Confirmed. The problem is that the test is run with -pedantic-errors. Before the patch, gfortran emits warnings with this option before the patch, while it emits errors with the patch.
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #11 from Dominique d'Humieres --- I think you need to add a line ! { dg-options "-pedantic" } to elemental_optional_args_6.f90 (untested).
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #12 from Dominique d'Humieres --- I have tested that the following patch fixes the failures --- ../_clean/gcc/testsuite/gfortran.dg/elemental_optional_args_6.f90 2012-06-18 21:04:16.0 +0200 +++ gcc/testsuite/gfortran.dg/elemental_optional_args_6.f90 2016-01-30 17:12:57.0 +0100 @@ -1,4 +1,5 @@ ! { dg-do run } +! { dg-options "-pedantic" } ! ! PR fortran/53692 !
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #9 from janus at gcc dot gnu.org --- Created attachment 37527 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37527=edit patch The attached patch should take care of all cases mentioned above. Unfortunately it causes a testsuite failure of elemental_optional_args_6.f90 and I just cannot understand why :(
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #13 from Manuel López-Ibáñez --- (In reply to Dominique d'Humieres from comment #11) > I think you need to add a line > > ! { dg-options "-pedantic" } > > to elemental_optional_args_6.f90 (untested). I'd suggest to use -Wpedantic, since this is the "modern" name (and consistent with all the other -Wx flags) and it is what will be printed in the diagnostic. Moreover, -Wno-pedantic is valid, but -no-pedantic is not. With no dg-options, testcases are run with some default options, and those seem to include -pedantic-errors (no idea why).
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #8 from janus at gcc dot gnu.org --- (In reply to Manuel López-Ibáñez from comment #2) > Im sure there are more... One more case that I just ran across by coincidence (from resolve.c): if (warn_compare_reals) { gfc_intrinsic_op op = e->value.op.op; /* Type conversion has made sure that the types of op1 and op2 agree, so it is only necessary to check the first one. */ if ((op1->ts.type == BT_REAL || op1->ts.type == BT_COMPLEX) && (op == INTRINSIC_EQ || op == INTRINSIC_EQ_OS || op == INTRINSIC_NE || op == INTRINSIC_NE_OS)) { const char *msg; if (op == INTRINSIC_EQ || op == INTRINSIC_EQ_OS) msg = "Equality comparison for %s at %L"; else msg = "Inequality comparison for %s at %L"; gfc_warning (0, msg, gfc_typename (>ts), >where); } }
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #7 from janus at gcc dot gnu.org --- (In reply to Manuel López-Ibáñez from comment #5) > (In reply to janus from comment #4) > > Is there a reason for this behavior? > > https://gcc.gnu.org/wiki/FAQ#wnowarning I see. So this is intended and not a bug. Thanks for the pointer. > But the third call should have given some other warning; otherwise there is > a bug. Right, there was a warning. I just omitted it because I did not expect that it makes a difference.
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #3 from janus at gcc dot gnu.org --- (In reply to Manuel López-Ibáñez from comment #2) > I think there must be a lot more cases of this: Yes, those should be taken care of as well. I'll try to do that. I guess practically all occurrences of "gfc_warning (0, ..." need to be transformed, or are there cases where the zero is legitimate?
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #4 from janus at gcc dot gnu.org --- Btw, I noticed another loosely related issue concerning misspellings of the warning flags: $ gfortran -Wunused-labels test.f90 gfortran: error: unrecognized command line option ‘-Wunused-labels’ $ gfortran -Wno-unused-labels test.f90 (no error!) $ gfortran -Wall -Wno-unused-labels test.f90 f951: Warning: unrecognized command line option ‘-Wno-unused-labels’ This seems very inconsistent: All three calls involve an invalid flag, but the diagnostics is very different for each of them (it's particularly bad that the second case does not give any kind of feedback). Is there a reason for this behavior?
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #5 from Manuel López-Ibáñez --- (In reply to janus from comment #4) > This seems very inconsistent: All three calls involve an invalid flag, but > the diagnostics is very different for each of them (it's particularly bad > that the second case does not give any kind of feedback). Is there a reason > for this behavior? https://gcc.gnu.org/wiki/FAQ#wnowarning But the third call should have given some other warning; otherwise there is a bug.
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 --- Comment #6 from Manuel López-Ibáñez --- (In reply to janus from comment #3) > I guess practically all occurrences of "gfc_warning (0, ..." need to be > transformed, or are there cases where the zero is legitimate? Most warnings don't have a command-line option associated to them, they are enabled by default and cannot be disabled. I'm not sure whether they should, this is up to the gfortran maintainers. The consensus in C/C++ so far has been that adding options for all warnings would add too many options that nobody uses. Clang does associate an option to every warning. Other warnings that can be enabled/disabled by an option must use the corresponding OPT_ in the warning call.
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 janus at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2016-01-26 Assignee|unassigned at gcc dot gnu.org |janus at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from janus at gcc dot gnu.org --- Simple patch: Index: gcc/fortran/resolve.c === --- gcc/fortran/resolve.c (Revision 232803) +++ gcc/fortran/resolve.c (Arbeitskopie) @@ -14890,8 +14890,8 @@ switch (label->referenced) { case ST_LABEL_UNKNOWN: - gfc_warning (0, "Label %d at %L defined but not used", label->value, - >where); + gfc_warning (OPT_Wunused_label, "Label %d at %L defined but not used", + label->value, >where); break; case ST_LABEL_BAD_TARGET:
[Bug fortran/69495] unused-label warning does not tell which flag triggered it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495 Manuel López-Ibáñez changed: What|Removed |Added CC||manu at gcc dot gnu.org --- Comment #2 from Manuel López-Ibáñez --- I think there must be a lot more cases of this: if (!warn_surprising) return true; /* If we can't calculate the sizes, we cannot check any more. Return true for that case. */ if (!gfc_calculate_transfer_sizes (source, mold, size, _size, _size, NULL)) return true; if (source_size < result_size) gfc_warning (0, "Intrinsic TRANSFER at %L has partly undefined result: " "source size %ld < result size %ld", >where, (long) source_size, (long) result_size); . if (warn_function_elimination) do_warn_function_elimination (*ej); ... /* If warning about the standard, warn and succeed. */ if (gfc_option.warn_std & isym->standard) { /* Do only print a warning if not a GNU extension. */ if (!silent && isym->standard != GFC_STD_GNU) gfc_warning (0, "Intrinsic %qs (is %s) is used at %L", isym->name, _(symstd_msg), ); return true; } ... /* At this point, a conversion is necessary. A warning may be needed. */ if ((gfc_option.warn_std & sym->standard) != 0) { gfc_warning_now (0, "Extension: Conversion from %s to %s at %L", gfc_typename (_ts), gfc_typename (ts), >where); } .. if (pedantic && arg->expr != NULL && arg->expr->expr_type == EXPR_VARIABLE && arg->expr->symtree->n.sym->attr.optional && formal_optional && arg->expr->rank && (set_by_optional || arg->expr->rank != rank) && !(isym && isym->id == GFC_ISYM_CONVERSION)) { gfc_warning (0, "%qs at %L is an array and OPTIONAL; IF IT IS " "MISSING, it cannot be the actual argument of an " "ELEMENTAL procedure unless there is a non-optional " "argument with the same rank (12.4.1.5)", arg->expr->symtree->n.sym->name, >expr->where); } } if (warn_align_commons) { if (strcmp (common->name, BLANK_COMMON_NAME)) gfc_warning (0, "Padding of %d bytes required before %qs in " "COMMON %qs at %L; reorder elements or use " "-fno-align-commons", (int)offset, s->sym->name, common->name, >where); else gfc_warning (0, "Padding of %d bytes required before %qs in " "COMMON at %L; reorder elements or use " "-fno-align-commons", (int)offset, s->sym->name, >where); } .. /* Warn about unused labels. */ if (warn_unused_label) warn_unused_fortran_label (ns->st_labels); ... Im sure there are more...