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))
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. */
/* 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))
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)
return true;
}
+/* Change the warning disposition for LOC to match OPTSPEC. */
+
+void
+put_warning_spec_at (location_t loc, unsigned bits)
+{
+ gcc_checking_assert (!RESERVED_LOCATION_P (loc));
+
+ nowarn_spec_t optspec = nowarn_spec_t::from_bits (bits);
+ if (!optspec)
+ {
+ if (nowarn_map)
+ nowarn_map->remove (loc);
+ }
+ else
+ {
+ if (!nowarn_map)
+ nowarn_map = nowarn_map_t::create_ggc (32);
+ nowarn_map->put (loc, optspec);
+ }
+}
+
/* Copy the no-warning disposition from one location to another. */
void
nowarn_spec_t (opt_code);
+ static nowarn_spec_t from_bits (unsigned bits)
+ {
+ nowarn_spec_t spec;
+ spec.m_bits = bits;
+ return spec;
+ }
+
/* Return the raw bitset. */
operator unsigned() const
{
--- /dev/null
+// PR c++/115757
+// { dg-additional-options "-fmodules-ts -Wunused" }
+// { dg-module-cmi test }
+
+export module test;
+
+export template <typename T>
+void foo(T n [[maybe_unused]]) {
+ int x [[maybe_unused]];
+}
--- /dev/null
+// PR c++/115757
+// { dg-additional-options "-fmodules-ts -Wunused" }
+
+import test;
+
+int main() {
+ foo(0);
+}
at a location to disabled by default. */
extern bool suppress_warning_at (location_t, opt_code = all_warnings,
bool = true);
+/* Overwrite warning disposition bitmap for a location with given spec. */
+extern void put_warning_spec_at (location_t loc, unsigned);
/* Copy warning disposition from one location to another. */
extern void copy_warning (location_t, location_t);
/* Copy warning disposition from one expression to another. */
extern void copy_warning (tree, const_tree);
+/* Whether the tree might have a warning spec. */
+extern bool has_warning_spec (const_tree);
+/* Retrieve warning spec bitmap for tree streaming. */
+extern unsigned get_warning_spec (const_tree);
+/* Overwrite warning spec bitmap for a tree with given spec. */
+extern void put_warning_spec (tree, unsigned);
+
/* Return the zero-based number corresponding to the argument being
deallocated if FNDECL is a deallocation function or an out-of-bounds
value if it isn't. */
return;
copy_warning<gimple *, const gimple *>(to, from);
}
+
+/* Whether the tree might have a warning spec. */
+
+bool has_warning_spec (const_tree t)
+{
+ const location_t loc = get_location (t);
+ return !RESERVED_LOCATION_P (loc) && !get_no_warning_bit (t);
+}
+
+/* Retrieve warning dispostion bitmap for tree streaming. */
+
+unsigned
+get_warning_spec (const_tree t)
+{
+ const nowarn_spec_t *spec = get_nowarn_spec (t);
+ return spec ? *spec : 0;
+}
+
+/* Write warning disposition bitmap for streamed-in tree. */
+
+void
+put_warning_spec (tree t, unsigned bits)
+{
+ const location_t loc = get_location (t);
+ put_warning_spec_at (loc, bits);
+}