diff options
author | Michael Chastain <mec@google.com> | 2004-08-09 22:47:50 +0000 |
---|---|---|
committer | Michael Chastain <mec@google.com> | 2004-08-09 22:47:50 +0000 |
commit | 78c9050252787db32fd6c8aa0a68d8fe594a3694 (patch) | |
tree | c6124c94696687c8cdc504abfe7bb8522f91c95d | |
parent | 88e5ea782b40ef390d55c3d285c6631bc0091efc (diff) | |
download | gdb-78c9050252787db32fd6c8aa0a68d8fe594a3694.zip gdb-78c9050252787db32fd6c8aa0a68d8fe594a3694.tar.gz gdb-78c9050252787db32fd6c8aa0a68d8fe594a3694.tar.bz2 |
2004-08-09 Michael Chastain <mec.gnu@mindspring.com>
* lib/cp-support.exp: New file.
* lib/cp-support.exp (cp_test_type_class): New function.
* gdb.cp/derivation.exp: Use cp_test_ptype_class.
* gdb.cp/virtfunc.exp (test_one_ptype): Removed.
* gdb.cp/virtfunc.exp (test_ptype_of_classes): Use
cp_test_ptype_class.
-rw-r--r-- | gdb/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/derivation.exp | 133 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/virtfunc.exp | 504 | ||||
-rw-r--r-- | gdb/testsuite/lib/cp-support.exp | 469 |
4 files changed, 632 insertions, 483 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index b45ca20..2e3a36e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,14 @@ 2004-08-09 Michael Chastain <mec.gnu@mindspring.com> + * lib/cp-support.exp: New file. + * lib/cp-support.exp (cp_test_type_class): New function. + * gdb.cp/derivation.exp: Use cp_test_ptype_class. + * gdb.cp/virtfunc.exp (test_one_ptype): Removed. + * gdb.cp/virtfunc.exp (test_ptype_of_classes): Use + cp_test_ptype_class. + +2004-08-09 Michael Chastain <mec.gnu@mindspring.com> + * gdb.mi/mi2-basics.exp, gdb.mi/mi2-break.exp, gdb.mi/mi2-console.exp, gdb.mi/mi2-disassemble.exp, gdb.mi/mi2-eval.exp, gdb.mi/mi2-file.exp, gdb.mi/mi2-hack-cli.exp, diff --git a/gdb/testsuite/gdb.cp/derivation.exp b/gdb/testsuite/gdb.cp/derivation.exp index d82ab1f..6c98d3c 100644 --- a/gdb/testsuite/gdb.cp/derivation.exp +++ b/gdb/testsuite/gdb.cp/derivation.exp @@ -38,6 +38,8 @@ set bug_id 0 if { [skip_cplus_tests] } { continue } +load_lib "cp-support.exp" + set testfile "derivation" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} @@ -61,124 +63,91 @@ if ![runto 'marker1'] then { gdb_test "up" ".*main.*" "up from marker1" # Print class types and values. -# See virtfunc.exp for a discussion of ptype. # class A -set re_class "((struct|class) A \{${ws}public:|struct A \{)" -set re_fields "int a;${ws}int aa;" -set re_methods "A\\((void|)\\);${ws}int afoo\\((void|)\\);${ws}int foo\\((void|)\\);" -set re_synth_gcc_23 "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);" -set re_all_methods "($re_methods|$re_methods${ws}$re_synth_gcc_23|$re_synth_gcc_23${ws}$re_methods)" - gdb_test "print a_instance" "\\$\[0-9\]+ = \{a = 1, aa = 2\}" "print value of a_instance" -gdb_test_multiple "ptype a_instance" "ptype a_instance" { - -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" { - pass "ptype a_instance (no synth ops)" - } - -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods${ws}$nl\}$nl$gdb_prompt $" { - pass "ptype a_instance (with synth ops)" +cp_test_ptype_class \ + "ptype a_instance" "" "class" "A" \ + { + { field public "int a;" } + { field public "int aa;" } + { method public "A();" } + { method public "int afoo();" } + { method public "int foo();" } } - -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { - pass "ptype a_instance (with synth ops)" - } -} # class D -set re_class "class D : private A, public B, protected C \{${ws}public:" -set XX_class "class D : private A, public B, private C \{${ws}public:" -set re_fields "int d;${ws}int dd;" -set re_methods "D\\((void|)\\);${ws}int dfoo\\((void|)\\);${ws}int foo\\((void|)\\);" -set re_synth_gcc_23 "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);" -set re_all_methods "($re_methods|$re_methods${ws}$re_synth_gcc_23|$re_synth_gcc_23${ws}$re_methods)" - gdb_test_multiple "print d_instance" "print value of d_instance" { -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, d = 7, dd = 8\}$nl$gdb_prompt $" { pass "print value of d_instance" } } -gdb_test_multiple "ptype d_instance" "ptype d_instance" { - -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { - pass "ptype d_instance" - } - -re "type = $re_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" { - pass "ptype d_instance" - } - -re "type = $XX_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { - # This is a gcc bug, gcc/13539, gdb/1498. - # Fixed in gcc HEAD 2004-01-13 - setup_xfail "*-*-*" "gcc/13539" - fail "ptype d_instance" - } - -re "type = $XX_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" { - # This is a gcc bug, gcc/13539, gdb/1498. - # Fixed in gcc HEAD 2004-01-13 - setup_xfail "*-*-*" "gcc/13539" - fail "ptype d_instance" +cp_test_ptype_class \ + "ptype d_instance" "" "class" "D" \ + { + { base "private A" } + { base "public B" } + { base "protected C" } + { field public "int d;" } + { field public "int dd;" } + { method public "D();" } + { method public "int dfoo();" } + { method public "int foo();" } + } \ + "" \ + { + { "protected C" "private C" { setup_xfail "*-*-*" "gcc/13539" } } } -} # class E -set re_class "class E : public A, private B, protected C \{${ws}public:" -set XX_class "class E : public A, private B, private C \{${ws}public:" -set re_fields "int e;${ws}int ee;" -set re_methods "E\\((void|)\\);${ws}int efoo\\((void|)\\);${ws}int foo\\((void|)\\);" -set re_synth_gcc_23 "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);" -set re_all_methods "($re_methods|$re_methods${ws}$re_synth_gcc_23|$re_synth_gcc_23${ws}$re_methods)" - gdb_test_multiple "print e_instance" "print value of e_instance" { -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, e = 9, ee = 10\}$nl$gdb_prompt $" { pass "print value of e_instance" } } -gdb_test_multiple "ptype e_instance" "ptype e_instance" { - -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { - pass "ptype e_instance" - } - -re "type = $re_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" { - pass "ptype e_instance" - } - -re "type = $XX_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { - # This is a gcc bug, gcc/13539, gdb/1498. - # Fixed in gcc HEAD 2004-01-13 - setup_xfail "*-*-*" "gcc/13539" - fail "ptype e_instance" - } - -re "type = $XX_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" { - # This is a gcc bug, gcc/13539, gdb/1498. - # Fixed in gcc HEAD 2004-01-13 - setup_xfail "*-*-*" "gcc/13539" - fail "ptype e_instance" +cp_test_ptype_class \ + "ptype e_instance" "" "class" "E" \ + { + { base "public A" } + { base "private B" } + { base "protected C" } + { field public "int e;" } + { field public "int ee;" } + { method public "E();" } + { method public "int efoo();" } + { method public "int foo();" } + } \ + "" \ + { + { "protected C" "private C" { setup_xfail "*-*-*" "gcc/13539" } } } -} # class F -set re_class "class F : private A, public B, private C \{${ws}public:" -set re_fields "int f;${ws}int ff;" -set re_methods "F\\((void|)\\);${ws}int ffoo\\((void|)\\);${ws}int foo\\((void|)\\);" -set re_synth_gcc_23 "F & operator=\\(F const ?&\\);${ws}F\\(F const ?&\\);" -set re_all_methods "($re_methods|$re_methods${ws}$re_synth_gcc_23|$re_synth_gcc_23${ws}$re_methods)" - gdb_test_multiple "print f_instance" "print value of f_instance" { -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, f = 11, ff = 12\}$nl$gdb_prompt $" { pass "print value of f_instance" } } -gdb_test_multiple "ptype f_instance" "ptype f_instance" { - -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { - pass "ptype f_instance" +cp_test_ptype_class \ + "ptype f_instance" "" "class" "F" \ + { + { base "private A" } + { base "public B" } + { base "private C" } + { field public "int f;" } + { field public "int ff;" } + { method public "F();" } + { method public "int ffoo();" } + { method public "int foo();" } } - -re "type = $re_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" { - pass "ptype f_instance" - } -} # Print individual fields. diff --git a/gdb/testsuite/gdb.cp/virtfunc.exp b/gdb/testsuite/gdb.cp/virtfunc.exp index 6373d3f..0a0291d 100644 --- a/gdb/testsuite/gdb.cp/virtfunc.exp +++ b/gdb/testsuite/gdb.cp/virtfunc.exp @@ -18,8 +18,6 @@ # This file was written by Fred Fish. (fnf@cygnus.com) # And rewritten by Michael Chastain <mec.gnu@mindspring.com>. -set wsopt "\[\r\n\t \]*" -set ws "\[\r\n\t \]+" set nl "\[\r\n\]+" if $tracelevel then { @@ -28,6 +26,8 @@ if $tracelevel then { if { [skip_cplus_tests] } { continue } +load_lib "cp-support.exp" + set testfile "virtfunc" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} @@ -36,444 +36,146 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -# Test ptype of a class. -# -# Different C++ compilers produce different output. I build up regular -# expressions piece by piece to accommodate all the compilers that I -# have seen: gcc 2.95.3, gcc 3.3.2 (ABI 1), gcc 3.4 prerelease (ABI 2); -# and all the debug formats I have seen: dwarf-2 and stabs+. -# -# A complicated class declaration looks like this: -# -# class A : public virtual V { // re_class -# private: -# V * _vb$V; // re_vbptr -# int a; // re_fields -# -# public: // re_access_methods -# A & operator=(A const &); // re_synth_gcc_2 -# A(int, A const &); // ... -# A(int); // ... -# virtual int f(void); // re_methods -# } -# -# RE_CLASS matches the class declaration. C++ allows multiple ways of -# expressing this. -# -# struct ... { private: ... }; -# class ... { private: ... }; -# class ... { ... }; -# -# RE_VBPTR matches the virtual base declarations. gcc 2.95.3 sometimes -# emits these, but gcc 3.X.Y never emits these. The name depends on the -# debug format. -# -# RE_FIELDS matches the data fields of the class. -# RE_METHODS matches the methods explicitly declared for the class. -# -# RE_SYNTH_GCC_2 and RE_SYNTH_GCC_3 match the optional synthetic methods -# of the class. gcc -gstabs+ emits these methods, and gcc -gdwarf-2 -# does not. -# -# RE_ACCESS_METHODS is an access specifier after RE_FIELDS and before -# the methods (explicit methods and/or synthetic methods). -# There is also an RE_ACCESS_FIELDS. -# -# When I get HP-UX aCC, I hope that I can just add RE_SYNTH_ACC_NNN. -# -# Yet another twist: with gcc v2, ctor and dtor methods have a hidden -# argument in front, the "in-charge" flag. With gcc v3, there is no -# hidden argument; instead, there are multiple object functions for -# each ctor and dtor. -# -# -- chastain 2004-01-01 - -proc test_one_ptype { command testname re_class re_vbptr re_access_fields re_fields re_access_methods re_methods re_synth_gcc_2 re_synth_gcc_3 re_star } { - global gdb_prompt - global wsopt - global ws - global nl - - gdb_test_multiple "$command" "$testname" { - -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { - # gcc 2.95.3, dwarf-2, no vbptr - # gcc 3.X, abi 1, dwarf-2 - # gcc 3.X, abi 2, dwarf-2 - pass "$testname" - } - -re "type = $re_class${wsopt}$re_vbptr${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { - # gcc 2.95.3, dwarf-2, vbptr - # TODO: drow says the vbptr is a bug - pass "$testname" - } - -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_2${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { - # gcc 2.95.3, stabs+, no vbptr - pass "$testname" - } - -re "type = $re_class${wsopt}$re_vbptr${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_2${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { - # gcc 2.95.3, stabs+, vbptr - # TODO: drow says the vbptr is a bug - pass "$testname" - } - -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_3${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { - # gcc 3.X, abi 1, stabs+ - pass "$testname" - } - -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods${wsopt}$re_synth_gcc_3$nl\}$re_star$nl$gdb_prompt $" { - # gcc 3.X, abi 2, stabs+ - pass "$testname" - } - } - -} - proc test_ptype_of_classes {} { - global gdb_prompt - global ws - global nl # class VA - test_one_ptype "ptype VA" "ptype VA" \ - "((struct|class) VA \{${ws}public:|struct VA \{)" \ - "" \ - "" "int va;" \ - "" "" \ - "VA & operator=\\(VA const ?&\\);${ws}VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \ - "(VA & operator=\\(VA const ?&\\);${ws}|)VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \ - "" + cp_test_ptype_class \ + "ptype VA" "" "class" "VA" \ + { + { field public "int va;" } + } # class VB - test_one_ptype "ptype VB" "ptype VB" \ - "((struct|class) VB \{${ws}public:|struct VB \{)" \ - "" \ - "" "int vb;" \ - "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \ - "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ - "(VB & operator=\\(VB const ?&\\);${ws}|)VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ - "" + cp_test_ptype_class \ + "ptype VB" "" "class" "VB" \ + { + { field public "int vb;" } + { method public "int fvb();" } + { method public "virtual int vvb();" } + } # class V - test_one_ptype "ptype V" "ptype V" \ - "class V : public VA, public VB \{${ws}public:" \ - "" \ - "" "int w;" \ - "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ - "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - "" + cp_test_ptype_class \ + "ptype V" "" "class" "V" \ + { + { base "public VA" } + { base "public VB" } + { field public "int w;" } + { method public "int f();" } + { method public "virtual int vv();" } + } # class A - test_one_ptype "ptype A" "ptype A" \ - "class A : public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "" "int a;" \ - "public:" "virtual int f\\((void|)\\);" \ - "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ - "(A & operator=\\(A const ?&\\);${ws}|)A\\(A const ?&\\);${ws}A\\((void|)\\);" \ - "" + cp_test_ptype_class \ + "ptype A" "" "class" "A" \ + { + { base "public virtual V" } + { vbase "V" } + { field private "int a;" } + { method public "virtual int f();" } + } # class B - test_one_ptype "ptype B" "ptype B" \ - "class B : public A \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "" "int b;" \ - "public:" "virtual int f\\((void|)\\);" \ - "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \ - "(B & operator=\\(B const ?&\\);${ws}|)B\\(B const ?&\\);${ws}B\\((void|)\\);" \ - "" + cp_test_ptype_class \ + "ptype B" "" "class" "B" \ + { + { base "public A" } + { field private "int b;" } + { method public "virtual int f();" } + } # class C - test_one_ptype "ptype C" "ptype C" \ - "class C : public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "public:" "int c;" \ - "" "" \ - "C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \ - "(C & operator=\\(C const ?&\\);${ws}|)C\\(C const ?&\\);${ws}C\\((void|)\\);" \ - "" + cp_test_ptype_class \ + "ptype C" "" "class" "C" \ + { + { base "public virtual V" } + { vbase "V" } + { field public "int c;" } + } # class AD - test_one_ptype "ptype AD" "ptype AD" \ - "((struct|class) AD \{${ws}public:|struct AD \{)" \ - "" \ - "" "" \ - "" "virtual int vg\\((void|)\\);" \ - "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ - "(AD & operator=\\(AD const ?&\\);${ws}|)AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ - "" + cp_test_ptype_class \ + "ptype AD" "" "class" "AD" \ + { + { method public "virtual int vg();" } + } # class D - test_one_ptype "ptype D" "ptype D" \ - "class D : public AD, public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "public:" "int d;" \ - "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ - "" + cp_test_ptype_class \ + "ptype D" "" "class" "D" \ + { + { base "public AD" } + { base "public virtual V" } + { vbase "V" } + { method public "static void s();" } + { method public "virtual int vg();" } + { method public "virtual int vd();" } + { method public "int fd();" } + { field public "int d;" } + } # class E - # TODO: E does not show a vbptr for V. That seems strange. - test_one_ptype "ptype E" "ptype E" \ - "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \ - "" \ - "public:" "int e;" \ - "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ - "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \ - "(E & operator=\\(E const ?&\\);${ws}|)E\\(E const ?&\\);${ws}E\\((void|)\\);" \ - "" + cp_test_ptype_class \ + "ptype E" "" "class" "E" \ + { + { base "public B" } + { base "public virtual V" } + { base "public D" } + { base "public C" } + { vbase "V" } + { method public "virtual int f();" } + { method public "virtual int vg();" } + { method public "virtual int vv();" } + { field public "int e;" } + } # An instance of D - test_one_ptype "ptype dd" "ptype dd" \ - "class D : public AD, public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "public:" "int d;" \ - "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ - "" + cp_test_ptype_class "ptype dd" "" "class" "D" ibid # An instance of D * - test_one_ptype "ptype ppd" "ptype ppd" \ - "class D : public AD, public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "public:" "int d;" \ - "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ - " ?\\*" + cp_test_ptype_class "ptype ppd" "" "class" "D" ibid "*" # An instance of AD * # TODO: this should be named pADd, not pAd. - test_one_ptype "ptype pAd" "ptype pAd" \ - "((struct|class) AD \{${ws}public:|struct AD \{)" \ - "" \ - "" "" \ - "" "virtual int vg\\((void|)\\);" \ - "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ - "(AD & operator=\\(AD const ?&\\);${ws}|)AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ - " ?\\*" - - # An instance of A - - test_one_ptype "ptype a" "ptype a" \ - "class A : public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "" "int a;" \ - "public:" "virtual int f\\((void|)\\);" \ - "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ - "(A & operator=\\(A const ?&\\);${ws}|)A\\(A const ?&\\);${ws}A\\((void|)\\);" \ - "" - - # An instance of B - - test_one_ptype "ptype b" "ptype b" \ - "class B : public A \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "" "int b;" \ - "public:" "virtual int f\\((void|)\\);" \ - "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \ - "(B & operator=\\(B const ?&\\);${ws}|)B\\(B const ?&\\);${ws}B\\((void|)\\);" \ - "" - - # An instance of C - - test_one_ptype "ptype c" "ptype c" \ - "class C : public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "public:" "int c;" \ - "" "" \ - "C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \ - "(C & operator=\\(C const ?&\\);${ws}|)C\\(C const ?&\\);${ws}C\\((void|)\\);" \ - "" - - # An instance of D - - test_one_ptype "ptype d" "ptype d" \ - "class D : public AD, public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "public:" "int d;" \ - "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ - "" - - # An instance of E - - test_one_ptype "ptype e" "ptype e" \ - "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \ - "" \ - "public:" "int e;" \ - "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ - "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \ - "(E & operator=\\(E const ?&\\);${ws}|)E\\(E const ?&\\);${ws}E\\((void|)\\);" \ - "" - - # An instance of V - - test_one_ptype "ptype v" "ptype v" \ - "class V : public VA, public VB \{${ws}public:" \ - "" \ - "" "int w;" \ - "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ - "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - "" - - # An instance of VB - - test_one_ptype "ptype vb" "ptype vb" \ - "((struct|class) VB \{${ws}public:|struct VB \{)" \ - "" \ - "" "int vb;" \ - "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \ - "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ - "(VB & operator=\\(VB const ?&\\);${ws}|)VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ - "" - - # An instance of A * - - test_one_ptype "ptype pAa" "ptype pAa" \ - "class A : public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "" "int a;" \ - "public:" "virtual int f\\((void|)\\);" \ - "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ - "(A & operator=\\(A const ?&\\);${ws}|)A\\(A const ?&\\);${ws}A\\((void|)\\);" \ - " ?\\*" - - # An instance of A * - - test_one_ptype "ptype pAe" "ptype pAe" \ - "class A : public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "" "int a;" \ - "public:" "virtual int f\\((void|)\\);" \ - "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ - "(A & operator=\\(A const ?&\\);${ws}|)A\\(A const ?&\\);${ws}A\\((void|)\\);" \ - " ?\\*" - - # An instance of B * - - test_one_ptype "ptype pBe" "ptype pBe" \ - "class B : public A \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "" "int b;" \ - "public:" "virtual int f\\((void|)\\);" \ - "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \ - "(B & operator=\\(B const ?&\\);${ws}|)B\\(B const ?&\\);${ws}B\\((void|)\\);" \ - " ?\\*" - - # An instance of D * - - test_one_ptype "ptype pDd" "ptype pDd" \ - "class D : public AD, public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "public:" "int d;" \ - "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ - " ?\\*" - - # An instance of D * - - test_one_ptype "ptype pDe" "ptype pDe" \ - "class D : public AD, public virtual V \{(${ws}private:|)" \ - "V \\*(_vb.1V|_vb.V);" \ - "public:" "int d;" \ - "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ - " ?\\*" - - # An instance of V * - - test_one_ptype "ptype pVa" "ptype pVa" \ - "class V : public VA, public VB \{${ws}public:" \ - "" \ - "" "int w;" \ - "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ - "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - " ?\\*" - - # An instance of V * - - test_one_ptype "ptype pVv" "ptype pVv" \ - "class V : public VA, public VB \{${ws}public:" \ - "" \ - "" "int w;" \ - "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ - "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - " ?\\*" - - # An instance of V * - - test_one_ptype "ptype pVe" "ptype pVe" \ - "class V : public VA, public VB \{${ws}public:" \ - "" \ - "" "int w;" \ - "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ - "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - " ?\\*" - - # An instance of V * - - test_one_ptype "ptype pVd" "ptype pVd" \ - "class V : public VA, public VB \{${ws}public:" \ - "" \ - "" "int w;" \ - "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ - "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ - " ?\\*" - - # An instance of AD * + cp_test_ptype_class "ptype pAd" "" "class" "AD" ibid "*" + + # Instances of these classes. + + cp_test_ptype_class "ptype a" "" "class" "A" ibid + cp_test_ptype_class "ptype b" "" "class" "B" ibid + cp_test_ptype_class "ptype c" "" "class" "C" ibid + cp_test_ptype_class "ptype d" "" "class" "D" ibid + cp_test_ptype_class "ptype e" "" "class" "E" ibid + cp_test_ptype_class "ptype v" "" "class" "V" ibid + cp_test_ptype_class "ptype vb" "" "class" "VB" ibid + + # Instances of pointers to these classes. + + cp_test_ptype_class "ptype pAa" "" "class" "A" ibid "*" + cp_test_ptype_class "ptype pAe" "" "class" "A" ibid "*" + cp_test_ptype_class "ptype pBe" "" "class" "B" ibid "*" + cp_test_ptype_class "ptype pDd" "" "class" "D" ibid "*" + cp_test_ptype_class "ptype pDe" "" "class" "D" ibid "*" + cp_test_ptype_class "ptype pVa" "" "class" "V" ibid "*" + cp_test_ptype_class "ptype pVv" "" "class" "V" ibid "*" + cp_test_ptype_class "ptype pVe" "" "class" "V" ibid "*" + cp_test_ptype_class "ptype pVd" "" "class" "V" ibid "*" + cp_test_ptype_class "ptype pADe" "" "class" "AD" ibid "*" + cp_test_ptype_class "ptype pEe" "" "class" "E" ibid "*" + cp_test_ptype_class "ptype pVB" "" "class" "VB" ibid "*" - test_one_ptype "ptype pADe" "ptype pADe" \ - "((struct|class) AD \{${ws}public:|struct AD \{)" \ - "" \ - "" "" \ - "" "virtual int vg\\((void|)\\);" \ - "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ - "(AD & operator=\\(AD const ?&\\);${ws}|)AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ - " ?\\*" - - # An instance of E * - - test_one_ptype "ptype pEe" "ptype pEe" \ - "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \ - "" \ - "public:" "int e;" \ - "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ - "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \ - "(E & operator=\\(E const ?&\\);${ws}|)E\\(E const ?&\\);${ws}E\\((void|)\\);" \ - " ?\\*" - - # An instance of VB * - - test_one_ptype "ptype pVB" "ptype pVB" \ - "((struct|class) VB \{${ws}public:|struct VB \{)" \ - "" \ - "" "int vb;" \ - "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \ - "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ - "(VB & operator=\\(VB const ?&\\);${ws}|)VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ - " ?\\*" } # Call virtual functions. diff --git a/gdb/testsuite/lib/cp-support.exp b/gdb/testsuite/lib/cp-support.exp new file mode 100644 index 0000000..7ce1e48 --- /dev/null +++ b/gdb/testsuite/lib/cp-support.exp @@ -0,0 +1,469 @@ +# This test code is part of GDB, the GNU debugger. + +# Copyright 2003, 2004 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Auxiliary function to check for known problems. +# +# EXPECTED_STRING is the string expected by the test. +# +# ACTUAL_STRING is the actual string output by gdb. +# +# ERRATA_TABLE is a list of lines of the form: +# +# { expected-string broken-string {eval-block} } +# +# If there is a line for the given EXPECTED_STRING, and if the +# ACTUAL_STRING output by gdb is the same as the BROKEN_STRING in the +# table, then I eval the eval-block. + +proc cp_check_errata { expected_string actual_string errata_table } { + foreach erratum $errata_table { + if { "$expected_string" == [lindex $erratum 0] + && "$actual_string" == [lindex $erratum 1] } then { + eval [lindex $erratum 2] + } + } +} + +# Test ptype of a class. +# +# Different C++ compilers produce different output. To accommodate all +# the variations listed below, I read the output of "ptype" and process +# each line, matching it to the class description given in the +# parameters. +# +# IN_COMMAND and IN_TESTNAME are the command and testname for +# gdb_test_multiple. If IN_TESTNAME is the empty string, then it +# defaults to IN_COMMAND. +# +# IN_KEY is "class" or "struct". For now, I ignore it, and allow either +# "class" or "struct" in the output, as long as the access specifiers all +# work out okay. +# +# IN_TAG is the class tag or structure tag. +# +# IN_CLASS_TABLE is a list of class information. Each entry contains a +# keyword and some values. The keywords and their values are: +# +# { base "base-declaration" } +# +# the class has a base with the given declaration. +# +# { vbase "name" } +# +# the class has a virtual base pointer with the given name. this +# is for gcc 2.95.3, which emits ptype entries for the virtual base +# pointers. the vbase list includes both indirect and direct +# virtual base classes (indeed, a virtual base is usually +# indirect), so this information cannot be derived from the base +# declarations. +# +# { field "access" "declaration" } +# +# the class has a data field with the given access type and the +# given declaration. +# +# { method "access" "declaration" } +# +# the class has a member function with the given access type +# and the given declaration. +# +# If you test the same class declaration more than once, you can specify +# IN_CLASS_TABLE as "ibid". "ibid" means: look for a previous class +# table that had the same IN_KEY and IN_TAG, and re-use that table. +# +# IN_TAIL is the expected text after the close brace, specifically the "*" +# in "struct { ... } *". This is an optional parameter. The default +# value is "", for no tail. +# +# IN_ERRATA_TABLE is a list of errata entries. See cp_check_errata for the +# format of the errata table. Note: the errata entries are not subject to +# demangler syntax adjustment, so you have to make a bigger table +# with lines for each output variation. +# +# gdb can vary the output of ptype in several ways: +# +# . CLASS/STRUCT +# +# The output can start with either "class" or "struct", depending on +# what the symbol table reader in gdb decides. This is usually +# unrelated to the original source code. +# +# dwarf-2 debug info distinguishes class/struct, but gdb ignores it +# stabs+ debug info does not distinguish class/struct +# hp debug info distinguishes class/struct, and gdb honors it +# +# I tried to accommodate this with regular expressions such as +# "((class|struct) A \{ public:|struct A \{)", but that turns into a +# hairy mess because of optional private virtual base pointers and +# optional public synthetic operators. This is the big reason I gave +# up on regular expressions and started parsing the output. +# +# . REDUNDANT ACCESS SPECIFIER +# +# In "class { private: ... }" or "struct { public: ... }", gdb might +# or might not emit a redundant initial access specifier, depending +# on the gcc version. +# +# . VIRTUAL BASE POINTERS +# +# If a class has virtual bases, either direct or indirect, the class +# will have virtual base pointers. With gcc 2.95.3, gdb prints lines +# for these virtual base pointers. This does not happen with gcc +# 3.3.4, gcc 3.4.1, or hp acc A.03.45. +# +# I accept these lines. These lines are optional; but if I see one of +# these lines, then I expect to see all of them. +# +# Note: drow considers printing these lines to be a bug in gdb. +# +# . SYNTHETIC METHODS +# +# A C++ compiler may synthesize some methods: an assignment +# operator, a copy constructor, a constructor, and a destructor. The +# compiler might include debug information for these methods. +# +# dwarf-2 gdb does not show these methods +# stabs+ gdb shows these methods +# hp gdb does not show these methods +# +# I accept these methods. These lines are optional, and any or +# all of them might appear, mixed in anywhere in the regular methods. +# +# With gcc v2, the synthetic copy-ctor and ctor have an additional +# "int" parameter at the beginning, the "in-charge" flag. +# +# . DEMANGLER SYNTAX VARIATIONS +# +# Different demanglers produce "int foo(void)" versus "int foo()", +# "const A&" versus "const A &", and so on. +# +# TESTED WITH +# +# gcc 2.95.3 -gdwarf-2 +# gcc 2.95.3 -gstabs+ +# gcc 3.3.4 -gdwarf-2 +# gcc 3.3.4 -gstabs+ +# gcc 3.4.1 -gdwarf-2 +# gcc 3.4.1 -gstabs+ +# gcc HEAD 20040731 -gdwarf-2 +# gcc HEAD 20040731 -gstabs+ +# +# TODO +# +# Tagless structs. +# +# "A*" versus "A *" and "A&" versus "A &" in user methods. +# +# Test with hp ACC. +# +# -- chastain 2004-08-07 + +proc cp_test_ptype_class { in_command in_testname in_key in_tag in_class_table { in_tail "" } { in_errata_table { } } } { + global gdb_prompt + set wsopt "\[\r\n\t \]*" + + # The test name defaults to the command. + + if { "$in_testname" == "" } then { set in_testname "$in_command" } + + # Save class tables in a history array for reuse. + + global cp_class_table_history + if { $in_class_table == "ibid" } then { + if { ! [info exists cp_class_table_history("$in_key,$in_tag") ] } then { + fail "$in_testname // bad ibid" + return + } + set in_class_table $cp_class_table_history("$in_key,$in_tag") + } else { + set cp_class_table_history("$in_key,$in_tag") $in_class_table + } + + # Split the class table into separate tables. + + set list_bases { } + set list_vbases { } + set list_fields { } + set list_methods { } + + foreach class_line $in_class_table { + switch [lindex $class_line 0] { + "base" { lappend list_bases [lindex $class_line 1] } + "vbase" { lappend list_vbases [lindex $class_line 1] } + "field" { lappend list_fields [lrange $class_line 1 2] } + "method" { lappend list_methods [lrange $class_line 1 2] } + default { fail "$in_testname // bad line in class table: $class_line"; return; } + } + } + + # Construct a list of synthetic operators. + # These are: { count ccess-type regular-expression }. + + set list_synth { } + lappend list_synth [list 0 "public" "$in_tag & operator=\\($in_tag const ?&\\);"] + lappend list_synth [list 0 "public" "$in_tag\\((int,|) ?$in_tag const ?&\\);"] + lappend list_synth [list 0 "public" "$in_tag\\((int|void|)\\);"] + + # Actually do the ptype. + + set parse_okay 0 + gdb_test_multiple "$in_command" "$in_testname // parse failed" { + -re "type = (struct|class)${wsopt}(\[A-Za-z0-9_\]*)${wsopt}((:\[^\{\]*)?)${wsopt}\{(.*)\}${wsopt}(\[^\r\n\]*)\[\r\n\]+$gdb_prompt $" { + set parse_okay 1 + set actual_key $expect_out(1,string) + set actual_tag $expect_out(2,string) + set actual_base_string $expect_out(3,string) + set actual_body $expect_out(5,string) + set actual_tail $expect_out(6,string) + } + } + if { ! $parse_okay } then { return } + + # Check the actual key. It would be nice to require that it match + # the input key, but gdb does not support that. For now, accept any + # $actual_key as long as the access property of each field/method + # matches. + + switch "$actual_key" { + "class" { set access "private" } + "struct" { set access "public" } + default { + cp_check_errata "class" "$actual_key" $in_errata_table + cp_check_errata "struct" "$actual_key" $in_errata_table + fail "$in_testname // wrong key: $actual_key" + return + } + } + + # Check the actual tag. + + if { "$actual_tag" != "$in_tag" } then { + cp_check_errata "$in_tag" "$actual_tag" $in_errata_table + fail "$in_testname // wrong tag: $actual_tag" + return + } + + # Check the actual bases. + # First parse them into a list. + + set list_actual_bases { } + if { "$actual_base_string" != "" } then { + regsub "^:${wsopt}" $actual_base_string "" actual_base_string + set list_actual_bases [split $actual_base_string ","] + } + + # Check the base count. + + if { [llength $list_actual_bases] < [llength $list_bases] } then { + fail "$in_testname // too few bases" + return + } + if { [llength $list_actual_bases] > [llength $list_bases] } then { + fail "$in_testname // too many bases" + return + } + + # Check each base. + + foreach actual_base $list_actual_bases { + set actual_base [string trim $actual_base] + set base [lindex $list_bases 0] + if { "$actual_base" != "$base" } then { + cp_check_errata "$base" "$actual_base" $in_errata_table + fail "$in_testname // wrong base: $actual_base" + return + } + set list_bases [lreplace $list_bases 0 0] + } + + # Parse each line in the body. + + set last_was_access 0 + set vbase_match 0 + + foreach actual_line [split $actual_body "\r\n"] { + + # Chomp the line. + + set actual_line [string trim $actual_line] + if { "$actual_line" == "" } then { continue } + + # Access specifiers. + + if { [regexp "^(public|protected|private)${wsopt}:\$" "$actual_line" s0 s1] } then { + set access "$s1" + if { $last_was_access } then { + fail "$in_testname // redundant access specifier" + return + } + set last_was_access 1 + continue + } else { + set last_was_access 0 + } + + # Optional virtual base pointer. + + if { [ llength $list_vbases ] > 0 } then { + set vbase [lindex $list_vbases 0] + if { [ regexp "$vbase \\*(_vb.|_vb\\\$|__vb_)\[0-9\]*$vbase;" $actual_line ] } then { + if { "$access" != "private" } then { + cp_check_errata "private" "$access" $in_errata_table + fail "$in_testname // wrong access specifier for virtual base: $access" + return + } + set list_vbases [lreplace $list_vbases 0 0] + set vbase_match 1 + continue + } + } + + # Data field. + + if { [llength $list_fields] > 0 } then { + set field_access [lindex [lindex $list_fields 0] 0] + set field_decl [lindex [lindex $list_fields 0] 1] + if { "$actual_line" == "$field_decl" } then { + if { "$access" != "$field_access" } then { + cp_check_errata "$field_access" "$access" $in_errata_table + fail "$in_testname // wrong access specifier for field: $access" + return + } + set list_fields [lreplace $list_fields 0 0] + continue + } + + # Data fields must appear before synths and methods. + cp_check_errata "$field_decl" "$actual_line" $in_errata_table + fail "$in_testname // unrecognized line type 1: $actual_line" + return + } + + # Method function. + + if { [llength $list_methods] > 0 } then { + set method_access [lindex [lindex $list_methods 0] 0] + set method_decl [lindex [lindex $list_methods 0] 1] + if { "$actual_line" == "$method_decl" } then { + if { "$access" != "$method_access" } then { + cp_check_errata "$method_access" "$access" $in_errata_table + fail "$in_testname // wrong access specifier for method: $access" + return + } + set list_methods [lreplace $list_methods 0 0] + continue + } + + # gcc 2.95.3 shows "foo()" as "foo(void)". + regsub -all "\\(\\)" $method_decl "(void)" method_decl + if { "$actual_line" == "$method_decl" } then { + if { "$access" != "$method_access" } then { + cp_check_errata "$method_access" "$access" $in_errata_table + fail "$in_testname // wrong access specifier for method: $access" + return + } + set list_methods [lreplace $list_methods 0 0] + continue + } + } + + # Synthetic operators. These are optional and can be mixed in + # with the methods in any order, but duplicates are wrong. + # + # This test must come after the user methods, so that a user + # method which matches a synth-method pattern is treated + # properly as a user method. + + set synth_match 0 + for { set isynth 0 } { $isynth < [llength $list_synth] } { incr isynth } { + set synth [lindex $list_synth $isynth] + set synth_count [lindex $synth 0] + set synth_access [lindex $synth 1] + set synth_re [lindex $synth 2] + + if { [ regexp "$synth_re" "$actual_line" ] } then { + + if { "$access" != "$synth_access" } then { + cp_check_errata "$synth_access" "$access" $in_errata_table + fail "$in_testname // wrong access specifier for synthetic operator: $access" + return + } + + if { $synth_count > 0 } then { + cp_check_errata "$actual_line" "$actual_line" $in_errata_table + fail "$in_testname // duplicate synthetic operator: $actual_line" + } + + # Update the count in list_synth. + + incr synth_count + set synth [list $synth_count $synth_access "$synth_re"] + set list_synth [lreplace $list_synth $isynth $isynth $synth] + + # Match found. + + set synth_match 1 + break + } + } + if { $synth_match } then { continue } + + # Unrecognized line. + + if { [llength $list_methods] > 0 } then { + set method_decl [lindex [lindex $list_methods 0] 1] + cp_check_errata "$method_decl" "$actual_line" $in_errata_table + } + + fail "$in_testname // unrecognized line type 2: $actual_line" + return + } + + # Check for missing elements. + + if { $vbase_match } then { + if { [llength $list_vbases] > 0 } then { + fail "$in_testname // missing virtual base pointers" + return + } + } + + if { [llength $list_fields] > 0 } then { + fail "$in_testname // missing fields" + return + } + + if { [llength $list_methods] > 0 } then { + fail "$in_testname // missing methods" + return + } + + # Check the tail. + + set actual_tail [string trim $actual_tail] + if { "$actual_tail" != "$in_tail" } then { + cp_check_errata "$in_tail" "$actual_tail" $in_errata_table + fail "$in_testname // wrong tail: $actual_tail" + return + } + + # It all worked! + + pass "$in_testname" + return +} |