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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
>From cp/decl.c:check_redeclaration_exception_specification

  /* [except.spec]

     If any declaration of a function has an exception-specification,
     all declarations, including the definition and an explicit
     specialization, of that function shall have an
     exception-specification with the same set of type-ids.  */
  if (!DECL_IS_UNDECLARED_BUILTIN (old_decl)
      && !DECL_IS_UNDECLARED_BUILTIN (new_decl)
      && !comp_except_specs (new_exceptions, old_exceptions, ce_normal))
    {
      const char *const msg
        = G_("declaration of %qF has a different exception specifier");
      bool complained = true;
      location_t new_loc = DECL_SOURCE_LOCATION (new_decl);
      auto_diagnostic_group d;
      if (DECL_IN_SYSTEM_HEADER (old_decl))
        complained = pedwarn (new_loc, OPT_Wsystem_headers, msg, new_decl);
      else if (!flag_exceptions)
        /* We used to silently permit mismatched eh specs with
           -fno-exceptions, so make them a pedwarn now.  */
        complained = pedwarn (new_loc, OPT_Wpedantic, msg, new_decl);
      else
        error_at (new_loc, msg, new_decl);
      if (complained)
        inform (DECL_SOURCE_LOCATION (old_decl),
                "from previous declaration %qF", old_decl);
    }

The DECL_IN_SYSTEM_HEADER check seems wrong. I think it should be checking
new_decl instead.

Reply via email to