On 6 May 2012 20:45, Joseph S. Myers <jos...@codesourcery.com> wrote: >> >> One idea could be to have an additional auto_handle_option() that is >> generated from the awk scripts and called after all other >> handle_option functions. This function will populate a switch with >> group options and the respective calls to handle_option_generated for >> sub-options. >> >> Is this a good idea? Where would be the best place to call this function? > > That certainly seems one reasonable way to handle implications.
OK, so I implemented this in the patch below, and it generates code like: bool common_handle_option_auto (struct gcc_options *opts, struct gcc_options *opts_set, const struct cl_decoded_option *decoded, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, diagnostic_context *dc) { size_t scode = decoded->opt_index; int value = decoded->value; enum opt_code code = (enum opt_code) scode; gcc_assert (decoded->canonical_option_num_elements <= 2); switch (code) { case OPT_Wuninitialized: if (!opts_set->x_warn_maybe_uninitialized) handle_generated_option (opts, opts_set, OPT_Wmaybe_uninitialized, NULL, value, lang_mask, kind, loc, handlers, dc); break; case OPT_Wextra: if (!opts_set->x_warn_uninitialized) handle_generated_option (opts, opts_set, OPT_Wuninitialized, NULL, value, lang_mask, kind, loc, handlers, dc); break; case OPT_Wunused: if (!opts_set->x_warn_unused_but_set_variable) handle_generated_option (opts, opts_set, OPT_Wunused_but_set_variable, NULL, value, lang_mask, kind, loc, handlers, dc); if (!opts_set->x_warn_unused_function) handle_generated_option (opts, opts_set, OPT_Wunused_function, NULL, value, lang_mask, kind, loc, handlers, dc); if (!opts_set->x_warn_unused_label) handle_generated_option (opts, opts_set, OPT_Wunused_label, NULL, value, lang_mask, kind, loc, handlers, dc); if (!opts_set->x_warn_unused_value) handle_generated_option (opts, opts_set, OPT_Wunused_value, NULL, value, lang_mask, kind, loc, handlers, dc); if (!opts_set->x_warn_unused_variable) handle_generated_option (opts, opts_set, OPT_Wunused_variable, NULL, value, lang_mask, kind, loc, handlers, dc); break; default: break; } return true; } which looks correct to me. However, the build fails because now options.h requires input.h which requires line-map.h, which is not included when building for example libgcc. options.h is included by tm.h, so it basically appears everywhere. Any suggestions how to fix this? Cheers, Manuel. > > -- > Joseph S. Myers > jos...@codesourcery.com
group-options-2.diff
Description: Binary data