aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/module.cc
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-07-07 13:56:25 +1000
committerThomas Koenig <tkoenig@gcc.gnu.org>2024-07-28 19:05:59 +0200
commit7a88eb35ef4834fcd98408fe5505360fead99f43 (patch)
tree52eb05601ab67b2b567f7b7992ef38a05304db84 /gcc/cp/module.cc
parent141ad69ba60f4c22382b66240a1c6c2104102846 (diff)
downloadgcc-7a88eb35ef4834fcd98408fe5505360fead99f43.zip
gcc-7a88eb35ef4834fcd98408fe5505360fead99f43.tar.gz
gcc-7a88eb35ef4834fcd98408fe5505360fead99f43.tar.bz2
c++/modules: Stream warning suppressions [PR115757]
Currently we don't stream the contents of 'nowarn_map'; this means that warning suppressions don't get applied in importers, which is particularly relevant for templates (as in the linked testcase). Rather than streaming the whole contents of 'nowarn_map', this patch instead just streams the exported suppressions for each tree node individually, to not build up additional locations and suppressions for tree nodes that do not need to be streamed. PR c++/115757 gcc/cp/ChangeLog: * module.cc (trees_out::core_vals): Write warning specs for DECLs and EXPRs. (trees_in::core_vals): Read warning specs. gcc/ChangeLog: * tree.h (put_warning_spec_at): Declare new function. (has_warning_spec): Likewise. (get_warning_spec): Likewise. (put_warning_spec): Likewise. * diagnostic-spec.h (nowarn_spec_t::from_bits): New function. * diagnostic-spec.cc (put_warning_spec_at): New function. * warning-control.cc (has_warning_spec): New function. (get_warning_spec): New function. (put_warning_spec): New function. gcc/testsuite/ChangeLog: * g++.dg/modules/warn-spec-1_a.C: New test. * g++.dg/modules/warn-spec-1_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc/cp/module.cc')
-rw-r--r--gcc/cp/module.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 69764fd..d1607a0 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -6000,6 +6000,10 @@ trees_out::core_vals (tree t)
if (state)
state->write_location (*this, t->decl_minimal.locus);
+
+ if (streaming_p ())
+ if (has_warning_spec (t))
+ u (get_warning_spec (t));
}
if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
@@ -6113,6 +6117,10 @@ trees_out::core_vals (tree t)
if (state)
state->write_location (*this, t->exp.locus);
+ if (streaming_p ())
+ if (has_warning_spec (t))
+ u (get_warning_spec (t));
+
/* Walk in forward order, as (for instance) REQUIRES_EXPR has a
bunch of unscoped parms on its first operand. It's safer to
create those in order. */
@@ -6576,6 +6584,8 @@ trees_in::core_vals (tree t)
/* Don't zap the locus just yet, we don't record it correctly
and thus lose all location information. */
t->decl_minimal.locus = state->read_location (*this);
+ if (has_warning_spec (t))
+ put_warning_spec (t, u ());
}
if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
@@ -6654,6 +6664,8 @@ trees_in::core_vals (tree t)
if (CODE_CONTAINS_STRUCT (code, TS_EXP))
{
t->exp.locus = state->read_location (*this);
+ if (has_warning_spec (t))
+ put_warning_spec (t, u ());
bool vl = TREE_CODE_CLASS (code) == tcc_vl_exp;
for (unsigned limit = (vl ? VL_EXP_OPERAND_LENGTH (t)