home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / gdb / testsuite / gdb.t22 / virtfunc.exp < prev    next >
Encoding:
Text File  |  1993-05-12  |  23.3 KB  |  675 lines

  1. # Copyright (C) 1992 Free Software Foundation, Inc.
  2.  
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with this program; if not, write to the Free Software
  13. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  14.  
  15. # Please email any bugs, comments, and/or additions to this file to:
  16. # bug-gdb@prep.ai.mit.edu
  17.  
  18. # This file was written by Fred Fish. (fnf@cygnus.com)
  19.  
  20. if $tracelevel then {
  21.     strace $tracelevel
  22. }
  23.  
  24. #
  25. #  Test printing of the types of various classes.
  26. #
  27.  
  28. proc test_ptype_of_classes {} {
  29.     global prompt
  30.  
  31.     set passcount 0
  32.  
  33.     send "ptype VA\n"
  34.     setup_xfail "*-*-*"
  35.     expect {
  36.     -re "type = class VA \{\[\r\n\t \]*int va;\r\n\}\r\n$prompt $" {
  37.         incr passcount
  38.     }
  39.     -re "type = struct VA \{\[\r\n\t \]*int va;\r\n\}\r\n$prompt $" {
  40.         fail "ptype VA (prints struct instead of class)"
  41.     }
  42.     -re ".*$prompt $" { fail "ptype VA" }
  43.     timeout { fail "ptype VA (timeout)" }
  44.     }
  45.  
  46.     send "ptype VB\n"
  47.     expect {
  48.     -re "type = class VB \{\[\r\n\t \]*public:\[\r\n\t \]*int vb;\[\r\n\t \]*int fvb\(void\);\[\r\n\t \]*virtual int vvb\(void\);\r\n\}\r\n$prompt $" {
  49.         incr passcount
  50.     }
  51.     -re "type = struct VB \{\[\r\n\t \]*int vb;\[\r\n\t \]*\}\r\n$prompt $" {
  52.         setup_xfail "*-*-*"
  53.         fail "ptype VB"
  54.     }
  55.     -re ".*$prompt $" { fail "ptype VB" }
  56.     timeout { fail "ptype VB (timeout)" }
  57.     }
  58.  
  59.     send "ptype V\n"
  60.     expect {
  61.     -re "type = class V : public VA, public VB \{\[\r\n\t \]*public:\[\r\n\t \]*int w;\[\r\n\t \]*int f\(void\);\[\r\n\t \]*virtual int vv\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  62.         incr passcount
  63.     }
  64.     -re "type = struct V \{\[\r\n \t\]*struct VA VA;\[\r\n \t\]*struct VB VB;\[\r\n \t\]*int w;\[\r\n \t\]*\}\r\n$prompt $" {
  65.         setup_xfail "*-*-*"
  66.         fail "ptype V"
  67.     }
  68.     -re ".*$prompt $" { fail "ptype V" }
  69.     timeout { fail "ptype V (timeout)" }
  70.     }
  71.  
  72.     send "ptype A\n"
  73.     expect {
  74.     -re "type = class A : public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*int a;\[\r\n\t \]*public:\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  75.         incr passcount
  76.     }
  77.     -re "type = struct A \{\[\r\n \t\]*struct V V;\[\r\n \t\]*struct V \*_vb\\\$V;\[\r\n \t\]*int a;\[\r\n \t\]*\}\r\n$prompt $" {
  78.         setup_xfail "*-*-*"
  79.         fail "ptype A"
  80.     }
  81.     -re ".*$prompt $" { fail "ptype A" }
  82.     timeout { fail "ptype A (timeout)" }
  83.     }
  84.  
  85.     send "ptype B\n"
  86.     expect {
  87.     -re "type = class B : public A \{\[\r\n\t \]*private:\[\r\n\t \]*int b;\[\r\n\t \]*public:\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  88.         incr passcount
  89.     }
  90.     -re "type = struct B \{\[\r\n \t\]*struct A A;\[\r\n \t\]*int b;\[\r\n \t\]*\}\r\n$prompt $" {
  91.         setup_xfail "*-*-*"
  92.         fail "ptype B"
  93.     }
  94.     -re ".*$prompt $" { fail "ptype B" }
  95.     timeout { fail "ptype B (timeout)" }
  96.     }
  97.  
  98.     send "ptype C\n"
  99.     expect {
  100.     -re "type = class C : public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*public:\[\r\n\t \]*int c;\[\r\n\t \]*\}\r\n$prompt $" {
  101.         incr passcount
  102.     }
  103.     -re "type = struct C \{\[\r\n \t\]*struct V V;\[\r\n \t\]*struct V \*_vb\\\$V;\[\r\n \t\]*int c;\[\r\n \t\]*\}\r\n$prompt $" {
  104.         setup_xfail "*-*-*"
  105.         fail "ptype C"
  106.     }
  107.     -re ".*$prompt $" { fail "ptype C" }
  108.     timeout { fail "ptype C (timeout)" }
  109.     }
  110.  
  111.     send "ptype AD\n"
  112.     expect {
  113.     -re "type = class AD \{\[\r\n\t \]*public:\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  114.         incr passcount
  115.     }
  116.     -re "type = struct AD \{\r\n\}\r\n$prompt $" {
  117.         setup_xfail "*-*-*"
  118.         fail "ptype AD"
  119.     }
  120.     -re ".*$prompt $" { fail "ptype AD" }
  121.     timeout { fail "ptype AD (timeout)" }
  122.     }
  123.  
  124.     send "ptype D\n"
  125.     expect {
  126.     -re "type = class D : public AD, public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*public:\[\r\n\t \]*int d;\[\r\n\t \]*static void s\(void\);\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*virtual int vd\(void\);\[\r\n\t \]*int fd\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  127.         incr passcount
  128.     }
  129.     -re "type = struct D \{\[\r\n\t \]*struct AD AD;\[\r\n\t \]*struct V V;\[\r\n\t \]*struct V \*_vb\\\$V;\[\r\n\t \]*int d;\[\r\n\t \]*\}\r\n$prompt $" {
  130.         setup_xfail "*-*-*"
  131.         fail "ptype D"
  132.     }
  133.     -re ".*$prompt $" { fail "ptype D" }
  134.     timeout { fail "ptype D (timeout)" }
  135.     }
  136.  
  137.     send "ptype E\n"
  138.     expect {
  139.     -re "type = class E : public B, public virtual V, public D, public C \{\[\r\n\t \]*public:\[\r\n\t \]*int e;\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*virtual int vv\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  140.         incr passcount
  141.     }
  142.     -re "type = struct E \{\[\r\n\t \]*struct B B;\[\r\n\t \]*struct V V;\[\r\n\t \]*struct D D;\[\r\n\t \]*struct C C;\[\r\n\t \]*int e;\[\r\n\t \]*\}\r\n$prompt $" {
  143.         setup_xfail "*-*-*"
  144.         fail "ptype E"
  145.     }
  146.     -re ".*$prompt $" { fail "ptype E" }
  147.     timeout { fail "ptype E (timeout)" }
  148.     }
  149.  
  150.     send "ptype dd\n"
  151.     expect {
  152.     -re "type = class D : public AD, public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*public:\[\r\n\t \]*int d;\[\r\n\t \]*static void s\(void\);\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*virtual int vd\(void\);\[\r\n\t \]*int fd\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  153.         incr passcount
  154.     }
  155.     -re "type = struct D \{\[\r\n\t \]*struct AD AD;\[\r\n\t \]*struct V V;\[\r\n\t \]*struct V \*_vb\\\$V;\[\r\n\t \]*int d;\[\r\n\t \]*\}\r\n$prompt $" {
  156.         setup_xfail "*-*-*"
  157.         fail "ptype dd"
  158.     }
  159.     -re ".*$prompt $" { fail "ptype dd" }
  160.     timeout { fail "ptype dd (timeout)" }
  161.     }
  162.  
  163.     send "ptype ppd\n"
  164.     expect {
  165.     -re "type = class D : public AD, public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*public:\[\r\n\t \]*int d;\[\r\n\t \]*static void s\(void\);\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*virtual int vd\(void\);\[\r\n\t \]*int fd\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  166.         incr passcount
  167.     }
  168.     -re "type = struct D \{\[\r\n\t \]*struct AD AD;\[\r\n\t \]*struct V V;\[\r\n\t \]*struct V \*_vb\\\$V;\[\r\n\t \]*int d;\[\r\n\t \]*\} \*\r\n$prompt $" {
  169.         setup_xfail "*-*-*"
  170.         fail "ptype ppd"
  171.     }
  172.     -re ".*$prompt $" { fail "ptype ppd" }
  173.     timeout { fail "ptype ppd (timeout)" }
  174.     }
  175.  
  176.     send "ptype pAd\n"
  177.     expect {
  178.     -re "type = class AD \{\[\r\n\t \]*public:\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  179.         incr passcount
  180.     }
  181.     -re "type = struct AD \{\r\n\} \*\r\n$prompt $" {
  182.         setup_xfail "*-*-*"
  183.         fail "ptype pAd"
  184.     }
  185.     -re ".*$prompt $" { fail "ptype pAd" }
  186.     timeout { fail "ptype pAd (timeout)" }
  187.     }
  188.  
  189.     send "ptype a\n"
  190.     expect {
  191.     -re "type = class A : public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*int a;\[\r\n\t \]*public:\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  192.         incr passcount
  193.     }
  194.     -re "type = struct A \{\[\r\n \t\]*struct V V;\[\r\n \t\]*struct V \*_vb\\\$V;\[\r\n \t\]*int a;\[\r\n \t\]*\}\r\n$prompt $" {
  195.         setup_xfail "*-*-*"
  196.         fail "ptype a"
  197.     }
  198.     -re ".*$prompt $" { fail "ptype a" }
  199.     timeout { fail "ptype a (timeout)" }
  200.     }
  201.  
  202.     send "ptype b\n"
  203.     expect {
  204.     -re "type = class B : public A \{\[\r\n\t \]*private:\[\r\n\t \]*int b;\[\r\n\t \]*public:\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  205.         incr passcount
  206.     }
  207.     -re "type = struct B \{\[\r\n \t\]*struct A A;\[\r\n \t\]*int b;\[\r\n \t\]*\}\r\n$prompt $" {
  208.         setup_xfail "*-*-*"
  209.         fail "ptype b"
  210.     }
  211.     -re ".*$prompt $" { fail "ptype b" }
  212.     timeout { fail "ptype b (timeout)" }
  213.     }
  214.  
  215.     send "ptype c\n"
  216.     expect {
  217.     -re "type = class C : public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*public:\[\r\n\t \]*int c;\[\r\n\t \]*\}\r\n$prompt $" {
  218.         incr passcount
  219.     }
  220.     -re "type = struct C \{\[\r\n \t\]*struct V V;\[\r\n \t\]*struct V \*_vb\\\$V;\[\r\n \t\]*int c;\[\r\n \t\]*\}\r\n$prompt $" {
  221.         setup_xfail "*-*-*"
  222.         fail "ptype c"
  223.     }
  224.     -re ".*$prompt $" { fail "ptype c" }
  225.     timeout { fail "ptype c (timeout)" }
  226.     }
  227.  
  228.     send "ptype d\n"
  229.     expect {
  230.     -re "type = class D : public AD, public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*public:\[\r\n\t \]*int d;\[\r\n\t \]*static void s\(void\);\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*virtual int vd\(void\);\[\r\n\t \]*int fd\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  231.         incr passcount
  232.     }
  233.     -re "type = struct D \{\[\r\n\t \]*struct AD AD;\[\r\n\t \]*struct V V;\[\r\n\t \]*struct V \*_vb\\\$V;\[\r\n\t \]*int d;\[\r\n\t \]*\}\r\n$prompt $" {
  234.         setup_xfail "*-*-*"
  235.         fail "ptype d"
  236.     }
  237.     -re ".*$prompt $" { fail "ptype d" }
  238.     timeout { fail "ptype d (timeout)" }
  239.     }
  240.  
  241.     send "ptype e\n"
  242.     expect {
  243.     -re "type = class E : public B, public virtual V, public D, public C \{\[\r\n\t \]*public:\[\r\n\t \]*int e;\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*virtual int vv\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  244.         incr passcount
  245.     }
  246.     -re "type = struct E \{\[\r\n\t \]*struct B B;\[\r\n\t \]*struct V V;\[\r\n\t \]*struct D D;\[\r\n\t \]*struct C C;\[\r\n\t \]*int e;\[\r\n\t \]*\}\r\n$prompt $" {
  247.         setup_xfail "*-*-*"
  248.         fail "ptype e"
  249.     }
  250.     -re ".*$prompt $" { fail "ptype e" }
  251.     timeout { fail "ptype e (timeout)" }
  252.     }
  253.  
  254.     send "ptype v\n"
  255.     expect {
  256.     -re "type = class V : public VA, public VB \{\[\r\n\t \]*public:\[\r\n\t \]*int w;\[\r\n\t \]*int f\(void\);\[\r\n\t \]*virtual int vv\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  257.         incr passcount
  258.     }
  259.     -re "type = struct V \{\[\r\n \t\]*struct VA VA;\[\r\n \t\]*struct VB VB;\[\r\n \t\]*int w;\[\r\n \t\]*\}\r\n$prompt $" {
  260.         setup_xfail "*-*-*"
  261.         fail "ptype v"
  262.     }
  263.     -re ".*$prompt $" { fail "ptype v" }
  264.     timeout { fail "ptype v (timeout)" }
  265.     }
  266.  
  267.     send "ptype vb\n"
  268.     expect {
  269.     -re "type = class VB \{\[\r\n\t \]*public:\[\r\n\t \]*int vb;\[\r\n\t \]*int fvb\(void\);\[\r\n\t \]*virtual int vvb\(void\);\[\r\n\t \]*\}\r\n$prompt $" {
  270.         incr passcount
  271.     }
  272.     -re "type = struct VB \{\[\r\n\t \]*int vb;\[\r\n\t \]*\}\r\n$prompt $" {
  273.         setup_xfail "*-*-*"
  274.         fail "ptype vb"
  275.     }
  276.     -re ".*$prompt $" { fail "ptype vb" }
  277.     timeout { fail "ptype vb (timeout)" }
  278.     }
  279.  
  280.     send "ptype pAa\n"
  281.     expect {
  282.     -re "type = class A : public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*int a;\[\r\n\t \]*public:\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  283.         incr passcount
  284.     }
  285.     -re "type = struct A \{\[\r\n \t\]*struct V V;\[\r\n \t\]*struct V \*_vb\\\$V;\[\r\n \t\]*int a;\[\r\n \t\]*\} \*\r\n$prompt $" {
  286.         setup_xfail "*-*-*"
  287.         fail "ptype pAa"
  288.     }
  289.     -re ".*$prompt $" { fail "ptype pAa" }
  290.     timeout { fail "ptype pAa (timeout)" }
  291.     }
  292.  
  293.     send "ptype pAe\n"
  294.     expect {
  295.     -re "type = class A : public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*int a;\[\r\n\t \]*public:\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  296.         incr passcount
  297.     }
  298.     -re "type = struct A \{\[\r\n \t\]*struct V V;\[\r\n \t\]*struct V \*_vb\\\$V;\[\r\n \t\]*int a;\[\r\n \t\]*\} \*\r\n$prompt $" {
  299.         setup_xfail "*-*-*"
  300.         fail "ptype pAe"
  301.     }
  302.     -re ".*$prompt $" { fail "ptype pAe" }
  303.     timeout { fail "ptype pAe (timeout)" }
  304.     }
  305.  
  306.     send "ptype pBe\n"
  307.     expect {
  308.     -re "type = class B : public A \{\[\r\n\t \]*private:\[\r\n\t \]*int b;\[\r\n\t \]*public:\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  309.         incr passcount
  310.     }
  311.     -re "type = struct B \{\[\r\n \t\]*struct A A;\[\r\n \t\]*int b;\[\r\n \t\]*\} \*\r\n$prompt $" {
  312.         setup_xfail "*-*-*"
  313.         fail "ptype pBe"
  314.     }
  315.     -re ".*$prompt $" { fail "ptype pBe" }
  316.     timeout { fail "ptype pBe (timeout)" }
  317.     }
  318.  
  319.     send "ptype pDd\n"
  320.     expect {
  321.     -re "type = class D : public AD, public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*public:\[\r\n\t \]*int d;\[\r\n\t \]*static void s\(void\);\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*virtual int vd\(void\);\[\r\n\t \]*int fd\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  322.         incr passcount
  323.     }
  324.     -re "type = struct D \{\[\r\n\t \]*struct AD AD;\[\r\n\t \]*struct V V;\[\r\n\t \]*struct V \*_vb\\\$V;\[\r\n\t \]*int d;\[\r\n\t \]*\} \*\r\n$prompt $" {
  325.         setup_xfail "*-*-*"
  326.         fail "ptype pDd"
  327.     }
  328.     -re ".*$prompt $" { fail "ptype pDd" }
  329.     timeout { fail "ptype pDd (timeout)" }
  330.     }
  331.  
  332.     send "ptype pDe\n"
  333.     expect {
  334.     -re "type = class D : public AD, public virtual V \{\[\r\n\t \]*private:\[\r\n\t \]*V \*_vb\\\$V;\[\r\n\t \]*public:\[\r\n\t \]*int d;\[\r\n\t \]*static void s\(void\);\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*virtual int vd\(void\);\[\r\n\t \]*int fd\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  335.         incr passcount
  336.     }
  337.     -re "type = struct D \{\[\r\n\t \]*struct AD AD;\[\r\n\t \]*struct V V;\[\r\n\t \]*struct V \*_vb\\\$V;\[\r\n\t \]*int d;\[\r\n\t \]*\} \*\r\n$prompt $" {
  338.         setup_xfail "*-*-*"
  339.         fail "ptype pDe"
  340.     }
  341.     -re ".*$prompt $" { fail "ptype pDe" }
  342.     timeout { fail "ptype pDe (timeout)" }
  343.     }
  344.  
  345.     send "ptype pVa\n"
  346.     expect {
  347.     -re "type = class V : public VA, public VB \{\[\r\n\t \]*public:\[\r\n\t \]*int w;\[\r\n\t \]*int f\(void\);\[\r\n\t \]*virtual int vv\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  348.         incr passcount
  349.     }
  350.     -re "type = struct V \{\[\r\n \t\]*struct VA VA;\[\r\n \t\]*struct VB VB;\[\r\n \t\]*int w;\[\r\n \t\]*\} \*\r\n$prompt $" {
  351.         setup_xfail "*-*-*"
  352.         fail "ptype pVa"
  353.     }
  354.     -re ".*$prompt $" { fail "ptype pVa" }
  355.     timeout { fail "ptype pVa (timeout)" }
  356.     }
  357.  
  358.     send "ptype pVv\n"
  359.     expect {
  360.     -re "type = class V : public VA, public VB \{\[\r\n\t \]*public:\[\r\n\t \]*int w;\[\r\n\t \]*int f\(void\);\[\r\n\t \]*virtual int vv\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  361.         incr passcount
  362.     }
  363.     -re "type = struct V \{\[\r\n \t\]*struct VA VA;\[\r\n \t\]*struct VB VB;\[\r\n \t\]*int w;\[\r\n \t\]*\} \*\r\n$prompt $" {
  364.         setup_xfail "*-*-*"
  365.         fail "ptype pVv"
  366.     }
  367.     -re ".*$prompt $" { fail "ptype pVv" }
  368.     timeout { fail "ptype pVv (timeout)" }
  369.     }
  370.  
  371.     send "ptype pVe\n"
  372.     expect {
  373.     -re "type = class V : public VA, public VB \{\[\r\n\t \]*public:\[\r\n\t \]*int w;\[\r\n\t \]*int f\(void\);\[\r\n\t \]*virtual int vv\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  374.         incr passcount
  375.     }
  376.     -re "type = struct V \{\[\r\n \t\]*struct VA VA;\[\r\n \t\]*struct VB VB;\[\r\n \t\]*int w;\[\r\n \t\]*\} \*\r\n$prompt $" {
  377.         setup_xfail "*-*-*"
  378.         fail "ptype pVe"
  379.     }
  380.     -re ".*$prompt $" { fail "ptype pVe" }
  381.     timeout { fail "ptype pVe (timeout)" }
  382.     }
  383.  
  384.     send "ptype pVd\n"
  385.     expect {
  386.     -re "type = class V : public VA, public VB \{\[\r\n\t \]*public:\[\r\n\t \]*int w;\[\r\n\t \]*int f\(void\);\[\r\n\t \]*virtual int vv\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  387.         incr passcount
  388.     }
  389.     -re "type = struct V \{\[\r\n \t\]*struct VA VA;\[\r\n \t\]*struct VB VB;\[\r\n \t\]*int w;\[\r\n \t\]*\} \*\r\n$prompt $" {
  390.         setup_xfail "*-*-*"
  391.         fail "ptype pVd"
  392.     }
  393.     -re ".*$prompt $" { fail "ptype pVd" }
  394.     timeout { fail "ptype pVd (timeout)" }
  395.     }
  396.  
  397.     send "ptype pADe\n"
  398.     expect {
  399.     -re "type = class AD \{\[\r\n\t \]*public:\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  400.         incr passcount
  401.     }
  402.     -re "type = struct AD \{\r\n\} \*\r\n$prompt $" {
  403.         setup_xfail "*-*-*"
  404.         fail "ptype pADe"
  405.     }
  406.     -re ".*$prompt $" { fail "ptype pADe" }
  407.     timeout { fail "ptype pADe (timeout)" }
  408.     }
  409.  
  410.     send "ptype pEe\n"
  411.     expect {
  412.     -re "type = class E : public B, public virtual V, public D, public C \{\[\r\n\t \]*public:\[\r\n\t \]*int e;\[\r\n\t \]*virtual int f\(void\);\[\r\n\t \]*virtual int vg\(void\);\[\r\n\t \]*virtual int vv\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  413.         incr passcount
  414.     }
  415.     -re "type = struct E \{\[\r\n\t \]*struct B B;\[\r\n\t \]*struct V V;\[\r\n\t \]*struct D D;\[\r\n\t \]*struct C C;\[\r\n\t \]*int e;\[\r\n\t \]*\} \*\r\n$prompt $" {
  416.         setup_xfail "*-*-*"
  417.         fail "ptype pEe"
  418.     }
  419.     -re ".*$prompt $" { fail "ptype pEe" }
  420.     timeout { fail "ptype pEe (timeout)" }
  421.     }
  422.  
  423.     send "ptype pVB\n"
  424.     expect {
  425.     -re "type = class VB \{\[\r\n\t \]*public:\[\r\n\t \]*int vb;\[\r\n\t \]*int fvb\(void\);\[\r\n\t \]*virtual int vvb\(void\);\[\r\n\t \]*\} \*\r\n$prompt $" {
  426.         incr passcount
  427.     }
  428.     -re "type = struct VB \{\[\r\n\t \]*int vb;\[\r\n\t \]*\} \*\r\n$prompt $" {
  429.         setup_xfail "*-*-*"
  430.         fail "ptype pVB"
  431.     }
  432.     -re ".*$prompt $" { fail "ptype pVB" }
  433.     timeout { fail "ptype pVB (timeout)" }
  434.     }
  435.  
  436.     if $passcount then {
  437.     pass "$passcount correct virtual function types printed"
  438.     }
  439. }
  440.  
  441. #
  442. #  Test calling of virtual functions.
  443. #
  444.  
  445. proc test_virtual_calls {} {
  446.     global prompt
  447.     global GDB
  448.  
  449.     set passcount 0
  450.  
  451.     send "print pAe->f()\n"
  452.     expect {
  453.     -re ".* = 20\r\n$prompt $" { incr passcount }
  454.     -re "Cannot invoke functions on this machine.*$prompt $"
  455.         { fail "print pAe->f() FIXME" }
  456.     -re "Structure has no component named f.*$prompt $" {
  457.         setup_xfail "*-*-*"
  458.         fail "print pAe->f()"
  459.     }
  460.     -re ".*$prompt $" { fail "print pAe->f()" }
  461.     timeout { fail "print pAe->f() (timeout)" }
  462.     eof { fail "print pAe->f() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  463.     }
  464.  
  465.     send "print pAa->f()\n"
  466.     expect {
  467.     -re ".* = 1\r\n$prompt $" { incr passcount }
  468.     -re "Cannot invoke functions on this machine.*$prompt $"
  469.         { fail "print pAa->f() FIXME" }
  470.     -re "Structure has no component named f.*$prompt $" {
  471.         setup_xfail "*-*-*"
  472.         fail "print pAa->f()"
  473.     }
  474.     -re ".*$prompt $" { fail "print pAa->f()" }
  475.     timeout { fail "print pAa->f() (timeout)" }
  476.     eof { fail "print pAa->f() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  477.     }
  478.  
  479.     send "print pDe->vg()\n"
  480.     expect {
  481.     -re ".* = 202\r\n$prompt $" { incr passcount }
  482.     -re "Cannot invoke functions on this machine.*$prompt $"
  483.         { fail "print pDe->vg() FIXME" }
  484.     -re "Structure has no component named vg.*$prompt $" {
  485.         setup_xfail "*-*-*"
  486.         fail "print pDe->vg()"
  487.     }
  488.     -re ".*$prompt $" { fail "print pDe->vg()" }
  489.     timeout { fail "print pDe->vg() (timeout)" }
  490.     eof { fail "print pDe->vg() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  491.     }
  492.  
  493.     send "print pADe->vg()\n"
  494.     expect {
  495.     -re ".* = 202\r\n$prompt $" { incr passcount }
  496.     -re "Cannot invoke functions on this machine.*$prompt $"
  497.         { fail "print pADe->vg() FIXME" }
  498.     -re "Structure has no component named vg.*$prompt $" {
  499.         setup_xfail "*-*-*"
  500.         fail "print pADe->vg()"
  501.     }
  502.     -re ".*$prompt $" { fail "print pADe->vg()" }
  503.     timeout { fail "print pADe->vg() (timeout)" }
  504.     eof { fail "print pADe->vg() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  505.     }
  506.  
  507.     send "print pDd->vg()\n"
  508.     expect {
  509.     -re ".* = 101\r\n$prompt $" { incr passcount }
  510.     -re "Cannot invoke functions on this machine.*$prompt $"
  511.         { fail "print pDd->vg() FIXME" }
  512.     -re "Structure has no component named vg.*$prompt $" {
  513.         setup_xfail "*-*-*"
  514.         fail "print pDd->vg()"
  515.     }
  516.     -re ".*$prompt $" { fail "print pDd->vg()" }
  517.     timeout { fail "print pDd->vg() (timeout)" }
  518.     eof { fail "print pDd->vg() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  519.     }
  520.  
  521.     send "print pEe->vvb()\n"
  522.     expect {
  523.     -re ".* = 411\r\n$prompt $" { incr passcount }
  524.     -re "Cannot invoke functions on this machine.*$prompt $"
  525.         { fail "print pEe->vvb() FIXME" }
  526.     -re "Structure has no component named vvb.*$prompt $" {
  527.         setup_xfail "*-*-*"
  528.         fail "print pEe->vvb()"
  529.     }
  530.     -re ".*$prompt $" { fail "print pEe->vvb()" }
  531.     timeout { fail "print pEe->vvb() (timeout)" }
  532.     eof { fail "print pEe->vvb() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  533.     }
  534.  
  535.     send "print pVB->vvb()\n"
  536.     expect {
  537.     -re ".* = 407\r\n$prompt $" { incr passcount }
  538.     -re "Cannot invoke functions on this machine.*$prompt $"
  539.         { fail "print pVb->vvb() FIXME" }
  540.     -re "Structure has no component named vvb.*$prompt $" {
  541.         setup_xfail "*-*-*"
  542.         fail "print pVB->vvb()"
  543.     }
  544.     -re ".*$prompt $" { fail "print pVB->vvb()" }
  545.     timeout { fail "print pVB->vvb() (timeout)" }
  546.     eof { fail "print pVB->vvb() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  547.     }
  548.  
  549.     send "print pBe->vvb()\n"
  550.     expect {
  551.     -re ".* = 411\r\n$prompt $" { incr passcount }
  552.     -re "Cannot invoke functions on this machine.*$prompt $"
  553.         { fail "print pBe->vvb() FIXME" }
  554.     -re "Structure has no component named vvb.*$prompt $" {
  555.         setup_xfail "*-*-*"
  556.         fail "print pBe->vvb()"
  557.     }
  558.     -re ".*$prompt $" { fail "print pBe->vvb()" }
  559.     timeout { fail "print pBe->vvb() (timeout)" }
  560.     eof { fail "print pBe->vvb() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  561.     }
  562.  
  563.     send "print pDe->vvb()\n"
  564.     expect {
  565.     -re ".* = 411\r\n$prompt $" { incr passcount }
  566.     -re "Cannot invoke functions on this machine.*$prompt $"
  567.         { fail "print pDe->vvb() FIXME" }
  568.     -re "Structure has no component named vvb.*$prompt $" {
  569.         setup_xfail "*-*-*"
  570.         fail "print pDe->vvb()"
  571.     }
  572.     -re ".*$prompt $" { fail "print pDe->vvb()" }
  573.     timeout { fail "print pDe->vvb() (timeout)" }
  574.     eof { fail "print pDe->vvb() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  575.     }
  576.  
  577.     send "print pEe->vd()\n"
  578.     expect {
  579.     -re ".* = 282\r\n$prompt $" { incr passcount }
  580.     -re "Cannot invoke functions on this machine.*$prompt $"
  581.         { fail "print pEe->vd() FIXME" }
  582.     -re "Structure has no component named vd.*$prompt $" {
  583.         setup_xfail "*-*-*"
  584.         fail "print pEe->vd()"
  585.     }
  586.     -re ".*$prompt $" { fail "print pEe->vd()" }
  587.     timeout { fail "print pEe->vd() (timeout)" }
  588.     eof { fail "print pEe->vd() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  589.     }
  590.  
  591.     send "print pEe->fvb()\n"
  592.     expect {
  593.     -re ".* = 311\r\n$prompt $" { incr passcount }
  594.     -re "Cannot invoke functions on this machine.*$prompt $"
  595.         { fail "print pEe->fvb() FIXME" }
  596.     -re "Structure has no component named fvb.*$prompt $" {
  597.         setup_xfail "*-*-*"
  598.         fail "print pEe->fvb()"
  599.     }
  600.     -re ".*$prompt $" { fail "print pEe->fvb()" }
  601.     timeout { fail "print pEe->fvb() (timeout)" }
  602.     eof { fail "print pEe->fvb() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  603.     }
  604.  
  605.     send "print pEe->D::vg()\n"
  606.     expect {
  607.     -re ".* = 102\r\n$prompt $" { incr passcount }
  608.     -re "Cannot invoke functions on this machine.*$prompt $"
  609.         { fail "print pEe->D::vg() FIXME" }
  610.     -re "There is no field named vg.*$prompt $" {
  611.         setup_xfail "*-*-*"
  612.         fail "print pEe->D::vg()"
  613.     }
  614.     -re ".*$prompt $" { fail "print pEe->D::vg()" }
  615.     timeout { fail "print pEe->D::vg() (timeout)" }
  616.     eof { fail "print pEe->D::vg() ($GDB dumped core) (FIXME)" ; gdb_start ; return }
  617.     }
  618.  
  619.     if $passcount then {
  620.     pass "$passcount correct virtual function calls"
  621.     }
  622. }
  623.  
  624.  
  625. proc do_tests {} {
  626.     global prms_id
  627.     global bug_id
  628.     global subdir
  629.     global objdir
  630.     global srcdir
  631.     global binfile
  632.     global prompt
  633.  
  634.     set prms_id 0
  635.     set bug_id 0
  636.  
  637.     # Start with a fresh gdb.
  638.  
  639.     gdb_exit
  640.     gdb_start
  641.     gdb_reinitialize_dir $srcdir/$subdir
  642.     gdb_load $objdir/$subdir/$binfile
  643.  
  644.     send "set language c++\n"
  645.     expect -re "$prompt $"
  646.     send "set width 0\n"
  647.     expect -re "$prompt $"
  648.  
  649.     test_ptype_of_classes
  650.  
  651.     if [ runto 'test_calls(void)' ] then {
  652.     test_virtual_calls
  653.     }
  654.  
  655.     if [istarget "a29k-*-udi"] then {
  656.     # FIXME: If PR 2415 is fixed, this is not needed.
  657.     gdb_target_udi
  658.     }
  659. }
  660.  
  661. # Check to see if we have an executable to test.  If not, then either we
  662. # haven't tried to compile one, or the compilation failed for some reason.
  663. # In either case, just notify the user and skip the tests in this file.
  664.  
  665. set binfile "gdbme"
  666. set srcfile $binfile.cc
  667.  
  668. if ![file exists $objdir/$subdir/$binfile] then {
  669.     warning "$binfile does not exist; tests suppressed."
  670. } else {
  671.     do_tests
  672. }
  673.