gdb/testsuite: enable running gdb.cp/classes.exp with clang
authorBruno Larsen <blarsen@redhat.com>
Wed, 7 Sep 2022 13:48:08 +0000 (15:48 +0200)
committerBruno Larsen <blarsen@redhat.com>
Fri, 11 Nov 2022 09:13:25 +0000 (10:13 +0100)
commit729421925aee0e5b0954e062d757ad917fc02838
treea0aa2472e93d8f583953987739924014f8d39fc8
parent9e9ffe8ee6c986e6788ad08b5635091e1f49b376
gdb/testsuite: enable running gdb.cp/classes.exp with clang

When attempting to run the gdb.cp/classes.exp test using Clang++, the
test fails to prepare with -Wnon-c-typedef-for-linkage like the
previously fixed gdb.cp/class2.exp. Upon fixing this, the test shows 5
unexpected failures. One such failures is:

ptype/r class class_with_public_typedef
type = class class_with_public_typedef {
  private:
    int a;
  public:
    class_with_public_typedef::INT b;

  private:
    typedef int INT;
}
(gdb) FAIL: gdb.cp/classes.exp: ptype class class_with_public_typedef // wrong access specifier for typedef: private

While g++ provided the following output:

ptype/r class class_with_public_typedef
type = class class_with_public_typedef {
  private:
    int a;
  public:
    class_with_public_typedef::INT b;

    typedef int INT;
}
(gdb) PASS: gdb.cp/classes.exp: ptype class class_with_public_typedef

This error happens because Clang does not add DW_AT_accessibility to
typedefs inside classes, and without this information GDB defaults to
assuming the typedef is private.  Since there is nothing that GDB can do
about this, these tests have been set as xfails, and Clang bug 57608 has
been filed.

Bug: https://github.com/llvm/llvm-project/issues/57608
Approved-by: Tom Tromey <tom@tromey.com>
gdb/testsuite/gdb.cp/classes.exp