[Bug other/67304] Allow front-ends to share command-line options with different behaviours
ibuclaw at gdcproject dot org
gcc-bugzilla@gcc.gnu.org
Tue Feb 21 08:59:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67304
--- Comment #4 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
I've just managed to have a brief time to think about this and look at how the
generator currently works, I think the following should be doable, and should
work with only one change to handle the fix-up of the opt index.
- Add a new flag called NoCombine.
- Options marked as such will not have flags or help combined in the code
generator, and be given a separate index in the options array after the
combined option itself.
- NoCombine should alias for the generated OPT_xxx enumeration.
- Back references should chain back to the original OPT_xxx entry in a linked
way, as the binary search in find_opt will guarantee that the last entry will
be matched first.
- The combined option should have all languages so that the diagnostic "is a
valid option for ..." references the correct frontends.
Example of generated code in options.h:
OPT_J = 115, /* -J */
/* OPT_J = 116, (CL_D) */ /* -J */
/* OPT_J = 117, (CL_Foo) */ /* -J */
And in options.c
{ "-J",
"-J<directory> Put MODULE files in 'directory'.",
0,
0,
NULL, NULL, N_OPTS, N_OPTS, 1, -1,
CL_D | CL_Foo | CL_Fortran | CL_JOINED | CL_SEPARATE,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, 0, CLVC_STRING, 0 },
{ "-J",
"-J <dir> Look for string imports in <dir>",
0,
0,
NULL, NULL, OPT_J, 115, 1, -1,
CL_D | CL_JOINED | CL_SEPARATE | CL_NOCOMBINE,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, 0, CLVC_STRING, 0 },
{ "-J",
"Generate JSON file.",
0,
0,
NULL, NULL, OPT_J, 116, 1, -1,
CL_Foo | CL_NOCOMBINE,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, 0, CLVC_BOOLEAN, 0 },
More information about the Gcc-bugs
mailing list