[Bug c++/91076] New: wrong class-key in mentioned in a diagnostic note

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 3 19:55:00 GMT 2019


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

            Bug ID: 91076
           Summary: wrong class-key in mentioned in a diagnostic note
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

When a type defined with one class-key (such as "class") contains a member such
as a pointer to the same type that uses a different class-key (such as
"struct") the C++ front-end replaces the original class-key associated with the
type with the one used in the member.  This causes problems in GCC code that
examines the class-key by using CLASSTYPE_DECLARED_CLASS (t) or by calling
class_key_or_enum_as_string ().  A test case illustrating this bug is as
follows:

$ cat a.C && gcc -S -Wall -Wextra a.C
class A   // uses CLASS
{
public:
  struct A *p;   // uses STRUCT
}
[[maybe_unused]];   // misleading warning refers to STRUCT
a.C:6:1: warning: attribute ignored in declaration of ‘struct A’ [-Wattributes]
    6 | [[maybe_unused]];   // misleading warning refers to STRUCT
      | ^
a.C:6:1: note: attribute for ‘struct A’ must follow the ‘struct’ keyword


More information about the Gcc-bugs mailing list