Home | History | Annotate | Line # | Download | only in gdb.compile
      1  1.1.1.4  christos # Copyright 2015-2024 Free Software Foundation, Inc.
      2      1.1  christos 
      3      1.1  christos # This program is free software; you can redistribute it and/or modify
      4      1.1  christos # it under the terms of the GNU General Public License as published by
      5      1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6      1.1  christos # (at your option) any later version.
      7      1.1  christos #
      8      1.1  christos # This program is distributed in the hope that it will be useful,
      9      1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10      1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11      1.1  christos # GNU General Public License for more details.
     12      1.1  christos #
     13      1.1  christos # You should have received a copy of the GNU General Public License
     14      1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15      1.1  christos 
     16      1.1  christos # Virtual method/inheritance tests for GDB's C++ compile feature.
     17      1.1  christos 
     18      1.1  christos load_lib compile-support.exp
     19      1.1  christos 
     20      1.1  christos standard_testfile .cc
     21      1.1  christos 
     22  1.1.1.4  christos require allow_cplus_tests
     23  1.1.1.4  christos 
     24  1.1.1.4  christos require is_c_compiler_gcc
     25      1.1  christos 
     26      1.1  christos if {[prepare_for_testing $testfile $testfile $srcfile \
     27      1.1  christos 	 {debug nowarnings c++}]} {
     28      1.1  christos     return -1
     29      1.1  christos }
     30      1.1  christos 
     31      1.1  christos if {![runto_main]} {
     32      1.1  christos     return -1
     33      1.1  christos }
     34      1.1  christos 
     35      1.1  christos gdb_breakpoint [gdb_get_line_number "break here" $srcfile]
     36      1.1  christos gdb_continue_to_breakpoint "testing location"
     37      1.1  christos 
     38  1.1.1.3  christos if {[skip_compile_feature_untested "var = 0"]} {
     39  1.1.1.3  christos     return -1
     40  1.1.1.3  christos }
     41  1.1.1.3  christos 
     42      1.1  christos CompileExpression::new "var"
     43      1.1  christos CompileExpression::test "b.doit ()" 2
     44      1.1  christos CompileExpression::test "c.doit ()" 3
     45      1.1  christos CompileExpression::test "d.doit ()" 4
     46      1.1  christos CompileExpression::test "ap->doit ()" 4
     47      1.1  christos CompileExpression::test "b.doit2 ()" 22
     48      1.1  christos CompileExpression::test "c.doit2 ()" 33
     49      1.1  christos CompileExpression::test "d.doit2 ()" 44
     50      1.1  christos CompileExpression::test "ap->doit2 ()" 44
     51      1.1  christos CompileExpression::test "b.doit3 ()" -3
     52      1.1  christos CompileExpression::test "c.doit3 ()" -3
     53      1.1  christos CompileExpression::test "d.doit3 ()" -3
     54      1.1  christos 
     55      1.1  christos # These two tests are "disabled".  They represent new/future features.
     56      1.1  christos # CompileExpression::test \
     57      1.1  christos     [concat "struct ABC {int doit2() { return 3333; }} abc;" \
     58      1.1  christos 	 "var = abc.doit2()"] \
     59      1.1  christos     3333 -explicit
     60      1.1  christos # CompileExpression::test \
     61      1.1  christos     [concat "struct ABC : A {int doit2() { return 4444; }} abc;" \
     62      1.1  christos 	 "var = abc.doit2()"] \
     63      1.1  christos     4444 -explicit
     64      1.1  christos 
     65      1.1  christos # Test some error conditions
     66      1.1  christos gdb_test "compile code A a;" \
     67      1.1  christos     ".*cannot declare variable .a. to be of abstract type.*Compilation failed."
     68