gfc_fatal_error ("Can't USE the same %smodule we're building!", p->state == COMP_SUBMODULE ? "sub" : ""); The message is either of these: * "Can't USE the same module we're building!" * "Can't USE the same submodule we're building!" As a translator, I have no chance of providing a proper translation for this, since the word part "sub" is always introduced. Translations should always be complete sentences. In this case, the easiest solution is this: for (p = gfc_state_stack; p; p = p->previous) if ((p->state == COMP_MODULE || p->state == COMP_SUBMODULE) && strcmp (p->sym->name, module_name) == 0) if (p->state == COMP_SUBMODULE) gfc_fatal_error ("Can't USE a submodule that is currently built"); else gfc_fatal_error ("Can't USE a module that is currently built"); This also fixes #79840 by removing the exclamation mark and rewording the diagnostic.
Do you agree with the change in comment 0? If yes, I can do the testing and packaging.
(In reply to Dominique d'Humieres from comment #1) > Do you agree with the change in comment 0? If yes, I can do the testing and > packaging. Yes, that's fine by me. Thanks Paul
Any progress on this one? To me it sounds like it were quite easy to fix.
Updated patch I am planning to commit --- ../_clean/gcc/fortran/module.c 2019-03-21 20:46:46.000000000 +0100 +++ gcc/fortran/module.c 2019-04-06 12:40:17.000000000 +0200 @@ -7144,8 +7144,10 @@ gfc_use_module (gfc_use_list *module) for (p = gfc_state_stack; p; p = p->previous) if ((p->state == COMP_MODULE || p->state == COMP_SUBMODULE) && strcmp (p->sym->name, module_name) == 0) - gfc_fatal_error ("Cannot USE the same %smodule we're building", - p->state == COMP_SUBMODULE ? "sub" : ""); + if (p->state == COMP_SUBMODULE) + gfc_fatal_error ("Cannot USE a submodule that is currently built"); + else + gfc_fatal_error ("Cannot USE a module that is currently built"); init_pi_tree (); init_true_name_tree (); AFAICT the errors are not covered by the test suite.
The patch in comment 4 does not bootstrap: ../../work/gcc/fortran/module.c: In function 'void gfc_use_module(gfc_use_list*)': ../../work/gcc/fortran/module.c:7145:8: error: suggest explicit braces to avoid ambiguous 'else' [-Werror=dangling-else] 7145 | if ((p->state == COMP_MODULE || p->state == COMP_SUBMODULE) | ^ cc1plus: all warnings being treated as errors This one does --- ../_clean/gcc/fortran/module.c 2019-03-21 20:46:46.000000000 +0100 +++ gcc/fortran/module.c 2019-04-06 16:39:02.000000000 +0200 @@ -7144,8 +7144,12 @@ gfc_use_module (gfc_use_list *module) for (p = gfc_state_stack; p; p = p->previous) if ((p->state == COMP_MODULE || p->state == COMP_SUBMODULE) && strcmp (p->sym->name, module_name) == 0) - gfc_fatal_error ("Cannot USE the same %smodule we're building", - p->state == COMP_SUBMODULE ? "sub" : ""); + { + if (p->state == COMP_SUBMODULE) + gfc_fatal_error ("Cannot USE a submodule that is currently built"); + else + gfc_fatal_error ("Cannot USE a module that is currently built"); + } init_pi_tree (); init_true_name_tree ();
Author: dominiq Date: Sat Apr 13 11:32:49 2019 New Revision: 270338 URL: https://gcc.gnu.org/viewcvs?rev=270338&root=gcc&view=rev Log: 2019-04-13 Dominique d'Humieres <dominiq@gcc.gnu.org> PR fortran/79842 * module.c (gfc_use_module): use complete sentences. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/module.c
Closing. It would be nice if someone commits tests covering the errors.