https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124466

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |nshead at gcc dot 
gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-03-13
           Keywords|                            |ice-on-valid-code

--- Comment #2 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Reduced:

  // a.cpp
  export module A;
  #define PUSH _Pragma("GCC diagnostic push")
  #define POP _Pragma("GCC diagnostic pop")
  PUSH
  #pragma GCC diagnostic ignored "-Wvariadic-macros"
  POP

  // b.cpp
  export module B;
  export import A;

  // c.cpp
  import B;

Root cause is in write_diagnostic_classification, the call to
linemap_location_from_module_p is returning true for the ignore, but false for
the pop.  It turns out that it doesn't follow macro locations to their
spelling; here's a patch I'm testing and will submit soon:

diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc
index 3dd73a93b98..34f3642258d 100644
--- a/libcpp/line-map.cc
+++ b/libcpp/line-map.cc
@@ -772,7 +772,9 @@ linemap_module_restore (line_maps *set, line_map_uint_t
lwm)
 bool
 linemap_location_from_module_p (const line_maps *set, location_t loc)
 {
-  const line_map_ordinary *map = linemap_ordinary_map_lookup (set, loc);
+  const line_map_ordinary *map = nullptr;
+  linemap_resolve_location (set, loc, LRK_SPELLING_LOCATION, &map);
+
   while (map && map->reason != LC_MODULE)
     map = linemap_included_from_linemap (set, map);
   return !!map;

Reply via email to