Thoughts? Another suggestion raised on the PR was to just make this a warning or some other non-fatal diagnostic (I suppose not attached to any particular warning option?) and continue translation; I'm not particularly fussed either way.
Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk/15.2? -- >8 -- This PR is the most frequently reported modules bug for 15, as the ICE message does not indicate the issue at all and reducing to find the underlying cause can be tricky. I have a WIP patch to fix this issue by just reconstructing these nodes on stream-in from any attributes applied to the functions, but since at this stage it may still take a while to be ready, it seems useful to me to at least make the error here more friendly and guide users to what they could do to work around this issue. PR c++/108080 gcc/cp/ChangeLog: * module.cc (trees_out::core_vals): Sorry when streaming target/optimize node. Adjust comments. (trees_in::core_vals): Don't stream a target/optimize node. gcc/testsuite/ChangeLog:Patrick Palka <ppa...@redhat.com> * g++.dg/modules/pr108080.H: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com> --- gcc/cp/module.cc | 29 ++++++++++++++++--------- gcc/testsuite/g++.dg/modules/pr108080.H | 5 +++++ 2 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/g++.dg/modules/pr108080.H diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 2f6a8ab98fa..b658f9fe2fc 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -6560,8 +6560,14 @@ trees_out::core_vals (tree t) } WT (t->function_decl.personality); - WT (t->function_decl.function_specific_target); - WT (t->function_decl.function_specific_optimization); + /* Rather than streaming target/optimize nodes, we should reconstruct + them on stream-in from any attributes applied to the function. */ + if (streaming_p () && t->function_decl.function_specific_target) + sorry_at (DECL_SOURCE_LOCATION (t), + "%<target%> attribute not currently supported in modules"); + if (streaming_p () && t->function_decl.function_specific_optimization) + sorry_at (DECL_SOURCE_LOCATION (t), + "%<optimize%> attribute not currently supported in modules"); WT (t->function_decl.vindex); if (DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (t)) @@ -6651,11 +6657,12 @@ trees_out::core_vals (tree t) case TARGET_OPTION_NODE: // FIXME: Our representation for these two nodes is a cache of // the resulting set of options. Not a record of the options - // that got changed by a particular attribute or pragma. Should - // we record that, or should we record the diff from the command - // 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? + // that got changed by a particular attribute or pragma. Instead + // of recording that, we probably should just rebuild the options + // on stream-in from the function attributes. This could introduce + // strangeness if the importer has some incompatible set of flags + // but we currently assume users "know what they're doing" in such + // a case anyway. gcc_unreachable (); break; @@ -7114,8 +7121,10 @@ trees_in::core_vals (tree t) } RT (t->function_decl.personality); - RT (t->function_decl.function_specific_target); - RT (t->function_decl.function_specific_optimization); + /* These properties are not streamed, and should be reconstructed + from any function attributes. */ + // t->function_decl.function_specific_target); + // t->function_decl.function_specific_optimization); RT (t->function_decl.vindex); if (DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (t)) @@ -7221,7 +7230,7 @@ trees_in::core_vals (tree t) case OPTIMIZATION_NODE: case TARGET_OPTION_NODE: - /* Not yet implemented, see trees_out::core_vals. */ + /* Not implemented, see trees_out::core_vals. */ gcc_unreachable (); break; diff --git a/gcc/testsuite/g++.dg/modules/pr108080.H b/gcc/testsuite/g++.dg/modules/pr108080.H new file mode 100644 index 00000000000..7f765126b20 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/pr108080.H @@ -0,0 +1,5 @@ +// PR c++/108080 +// { dg-additional-options "-fmodules" } +// Give a diagnostic message rather than a crash for unsupported features. + +[[gnu::optimize("-O3")]] void foo(); // { dg-message "sorry, unimplemented: .optimize." } -- 2.47.0