}
}
+ /* Process the diagnostics classification history. */
+ auto &chist = global_dc->get_classification_history ();
+ const int pop_offset = chist.length ();
+ using DK = diagnostics::kind;
+ for (size_t i = 0, nc = bp_unpack_var_len_unsigned (&bp); i != nc; ++i)
+ {
+ const size_t map_idx = bp_unpack_var_len_unsigned (&bp);
+ const location_t offset = bp_unpack_var_len_unsigned (&bp);
+ const location_t loc = get_location_from_idx (map_idx, offset, loc_map);
+ const int option = bp_unpack_var_len_int (&bp);
+ const auto kind = bp_unpack_enum (&bp, diagnostics::kind,
+ DK::tot_num_diagnostic_kinds);
+ if (kind == DK::pop)
+ {
+ diagnostics::option_classifier::classification_change_t c = {};
+ c.location = loc;
+ c.option = option + pop_offset;
+ c.kind = kind;
+ chist.safe_push (c);
+ }
+ else
+ global_dc->classify_diagnostic (option, kind, loc);
+ }
+ /* Make sure we reset back to the baseline. */
+ {
+ diagnostics::option_classifier::classification_change_t c = {};
+ c.location = line_table->highest_location;
+ c.kind = DK::pop;
+ chist.safe_push (c);
+ }
+
lto_data_in_delete (data_in);
lto_free_section_data (file_data, LTO_section_linemap, nullptr,
data, len, true);
const auto ob = create_output_block (LTO_section_linemap);
auto bp = bitpack_create (ob->main_stream);
+ /* Prepare the diagnostic classification history. To make life easier on the
+ reader, which will need to build the line map before processing the
+ classification history, we will stream it out after the line map data. But
+ we need to call record_location() now. */
+ const auto &chist = global_dc->get_classification_history ();
+ for (auto &c : chist)
+ record_location (c.location);
+
/* Sort the maps in the order they need to be inserted later. */
const size_t nmaps = map_data_map.elements ();
using KV = std::pair<const line_map_ordinary *, map_data>;
}
}
+ /* Output the diagnostics classification history. */
+ bp_pack_var_len_unsigned (&bp, chist.length ());
+ for (auto &c : chist)
+ {
+ const location_id_t loc_id = record_location (c.location);
+ bp_pack_var_len_unsigned (&bp, loc_id.map_id.idx);
+ bp_pack_var_len_unsigned (&bp, loc_id.offset);
+ bp_pack_var_len_int (&bp, c.option);
+ using DK = diagnostics::kind;
+ bp_pack_enum (&bp, DK, DK::tot_num_diagnostic_kinds, c.kind);
+ }
+
/* Finalize the section. */
streamer_write_bitpack (&bp);
{
--- /dev/null
+/* PR middle-end/106823 */
+/* { dg-lto-do link } */
+__attribute__((__warning__("w"))) void f (int) {}
+void g (int i)
+{
+ /* It would be nice to also confirm that the warning is issued in the
+ absence of the pragma, but the LTO testsuite is not currently set up to
+ test for warnings emitted during the compile stage. But pr80922
+ testcases do test this functionality. */
+ #pragma GCC diagnostic ignored "-Wattribute-warning"
+ f (i);
+}
+
+int main ()
+{
+ g (1);
+}
--- /dev/null
+/* PR lto/107936 */
+/* { dg-lto-do link } */
+/* { dg-lto-additional-options "-Wstringop-overflow" } */
+void foo (char x[2]);
+
+int
+main ()
+{
+ char x[2];
+ /* It would be nice to also confirm that the warning is issued in the
+ absence of the pragma, but the LTO testsuite is not currently set up to
+ test for warnings emitted during the compile stage. But pr80922
+ testcases do test this functionality. */
+ #pragma GCC diagnostic ignored "-Wstringop-overflow"
+ foo (x + 1);
+}
--- /dev/null
+void
+foo (char x[2])
+{
+ asm volatile ("" : : "r" (&x[0]) : "memory");
+}
--- /dev/null
+/* PR middle-end/80922 */
+
+/* { dg-lto-do link } */
+/* { dg-lto-additional-options "-O2 -Wfree-nonheap-object" } */
+
+void myfree (void *ptr1, void *ptr2, void *ptr3, void *ptr4)
+{
+ __builtin_free (ptr1); /* { dg-lto-warning "-Wfree-nonheap-object" } */
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wfree-nonheap-object"
+ __builtin_free (ptr2);
+ #pragma GCC diagnostic pop
+ __builtin_free (ptr3); /* { dg-lto-warning "-Wfree-nonheap-object" } */
+ _Pragma("GCC diagnostic push");
+ _Pragma("GCC diagnostic ignored \"-Wfree-nonheap-object\"");
+ #pragma GCC diagnostic push
+ __builtin_free (ptr4);
+}
+
+/* Since these two functions are in the same translation unit, the
+ diagnostic pragmas applied above are still in force. */
+void myfree2 (void *ptr1, void *ptr2, void *ptr3)
+{
+ __builtin_free (ptr1);
+ #pragma GCC diagnostic pop
+ __builtin_free (ptr2);
+ _Pragma("GCC diagnostic pop");
+ __builtin_free (ptr3); /* { dg-lto-warning "-Wfree-nonheap-object" } */
+}
--- /dev/null
+void myfree (void *, void *, void *, void *);
+void myfree2 (void *, void *, void *);
+
+static char a, b, c, d;
+int main ()
+{
+ myfree (&a, &b, &c, &d);
+ myfree2 (&a, &b, &c);
+}
--- /dev/null
+/* PR middle-end/80922 */
+/* This is similar to pr80922-1, but myfree() and myfree2() are split into
+ separate objects, so that they use two different line maps. */
+
+/* { dg-lto-do incr-link } */
+/* { dg-lto-additional-options "-O2 -Wfree-nonheap-object" } */
+
+void myfree (void *ptr1, void *ptr2, void *ptr3, void *ptr4)
+{
+ __builtin_free (ptr1); /* { dg-lto-warning "-Wfree-nonheap-object" } */
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wfree-nonheap-object"
+ __builtin_free (ptr2);
+ #pragma GCC diagnostic pop
+ __builtin_free (ptr3); /* { dg-lto-warning "-Wfree-nonheap-object" } */
+ _Pragma("GCC diagnostic ignored \"-Wfree-nonheap-object\"");
+ __builtin_free (ptr4);
+}
--- /dev/null
+/* The diagnostic pragmas left active in pr80922-2_0.c should not be in
+ force anymore. */
+void myfree2 (void *ptr1, void *ptr2, void *ptr3)
+{
+ __builtin_free (ptr1); /* { dg-lto-warning "-Wfree-nonheap-object" } */
+ _Pragma("GCC diagnostic push")
+ #pragma GCC diagnostic ignored "-Wfree-nonheap-object"
+ __builtin_free (ptr2);
+ _Pragma("GCC diagnostic pop");
+ __builtin_free (ptr3); /* { dg-lto-warning "-Wfree-nonheap-object" } */
+}
--- /dev/null
+#include "pr80922-1_1.c"