Record and output access specifiers for nested typedefs
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / classes.exp
index 256fa6885a096e732e1148036ab82f464743a71d..9e2630acef48715eadcac28d7a82cd24a436654e 100644 (file)
@@ -316,6 +316,64 @@ proc test_ptype_class_objects {} {
            { field  public "int y;" }
            { method public "DynamicBar(int, int);" }
        }
+
+    # Classes with typedefs of different access.
+
+    cp_test_ptype_class \
+       "class class_with_typedefs" "" "class" "class_with_typedefs" \
+       {
+           { field protected \
+                 "class_with_typedefs::public_int public_int_;" }
+           { field protected \
+                 "class_with_typedefs::protected_int protected_int_;" }
+           { field protected \
+                 "class_with_typedefs::private_int private_int_;" }
+           { method public "class_with_typedefs(void);" }
+           { method public "class_with_typedefs::public_int add_public(class_with_typedefs::public_int);" }
+           { method public \
+                 "class_with_typedefs::public_int add_all(int);" }
+           { method protected "class_with_typedefs::protected_int add_protected(class_with_typedefs::protected_int);" }
+           { method private "class_with_typedefs::private_int add_private(class_with_typedefs::private_int);" }
+           { typedef public "typedef int public_int;" }
+           { typedef protected "typedef int protected_int;" }
+           { typedef private "typedef int private_int;" }
+       }
+
+    cp_test_ptype_class \
+       "class class_with_public_typedef" "" "class" \
+       "class_with_public_typedef" {
+           { field private "int a;" }
+           { field public "class_with_public_typedef::INT b;" }
+           { typedef public "typedef int INT;" }
+       }
+    cp_test_ptype_class \
+       "class class_with_protected_typedef" "" "class" \
+       "class_with_protected_typedef" {
+           { field private "int a;" }
+           { field protected "class_with_protected_typedef::INT b;" }
+           { typedef protected "typedef int INT;" }
+       }
+    cp_test_ptype_class \
+       "struct struct_with_protected_typedef" "" "struct" \
+       "struct_with_protected_typedef" {
+           { field public "int a;" }
+           { field protected "struct_with_protected_typedef::INT b;" }
+           { typedef protected "typedef int INT;" }
+       }
+    cp_test_ptype_class \
+       "struct struct_with_private_typedef" "" "struct" \
+       "struct_with_private_typedef" {
+           { field public "int a;" }
+           { field private "struct_with_private_typedef::INT b;" }
+           { typedef private "typedef int INT;" }
+       }
+
+    # For the following two cases, we cannot use cp_test_ptype_class.
+    # We need to explicitly check whether the access label was suppressed.
+    set ws {[ \t\r\n]*}
+    foreach {tag lbl} {"class" "private" "struct" "public"} {
+       gdb_test "ptype/r ${tag}_with_${lbl}_typedef" "type = $tag ${tag}_with_${lbl}_typedef \{${ws}int a;${ws}${tag}_with_${lbl}_typedef::INT b;${ws}typedef int INT;${ws}\}"
+    }
 }
 
 # Test simple access to class members.
This page took 0.026576 seconds and 4 git commands to generate.