On 09/22/2015 08:08 PM, Manuel López-Ibáñez wrote:
Use find_opt instead of linear search through options in
handle_pragma_diagnostic (PR 49654) and reject non-warning options and
options not valid for the current language (PR 49655).
+ /* option_string + 1 to skip the initial '-' */
+ unsigned int lang_mask = c_common_option_lang_mask () | CL_COMMON;
+ unsigned int option_index = find_opt (option_string + 1, lang_mask);
Swap the first two lines to have the comment in the right spot.
+ else if (!(cl_options[option_index].flags & lang_mask))
+ {
+ char * ok_langs = write_langs (cl_options[option_index].flags);
+ char * bad_lang = write_langs (c_common_option_lang_mask ());
+ warning_at (loc, OPT_Wpragmas,
+ "option %qs is valid for %s but not for %s",
+ option_string, ok_langs, bad_lang);
+ free (ok_langs);
+ free (bad_lang);
+ return;
+ }
Slightly surprising, but I checked and find_opt is documented to return
an option for a different front end if it can't find a valid one
matching lang_mask.
Patch is ok.
Bernd