https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108080
ak at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ak at gcc dot gnu.org --- Comment #18 from ak at gcc dot gnu.org --- How about just making it a warning and ignore? In most cases this is not fatal. The only exception would be options that are required for correctness. This patch fixes the simple test case, except it can't figure out the location and the warning is printed multiple times. Still better than a ICE however. creating:./pr108080.cccc1plus: warning: optimization or target option changes ignored for modules cc1plus: warning: optimization or target option changes ignored for modules cc1plus: warning: optimization or target option changes ignored for modules cc1plus: warning: optimization or target option changes ignored for modules finishing:./pr108080.cc diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index a551509ec0b4..9d88283caaf0 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -6265,11 +6265,14 @@ trees_out::core_vals (tree t) #define WU(X) (u (X)) #define WT(X) (tree_node (X)) tree_code code = TREE_CODE (t); + location_t location = UNKNOWN_LOCATION; /* First by shape of the tree. */ if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL)) { + location = t->decl_minimal.locus; + /* Write this early, for better log information. */ WT (t->decl_minimal.name); if (!DECL_TEMPLATE_PARM_P (t)) @@ -6639,7 +6642,8 @@ trees_out::core_vals (tree t) // line options? The latter seems the right behaviour, but is // (a) harder, and I guess could introduce strangeness if the // importer has set some incompatible set of optimization flags? - gcc_unreachable (); + warning_at (location, 0, + "optimization or target option changes ignored for modules"); break; case TREE_BINFO: