Compile inline test with -std=gnu89 explicitly to override Clang's default (-std...
[external/binutils.git] / gdb / testsuite / gdb.opt / inline-break.exp
1 # Copyright 2012-2014 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 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 # Note that the testcase gdb.dwarf2/dw2-inline-break.exp largely
17 # mirrors this testcase, and should be updated if this testcase is
18 # changed.
19
20 standard_testfile
21
22 # Explicitly specify gnu89 for gnu inline semantics to override Clang's default
23 # of c99.
24 if { [prepare_for_testing $testfile.exp $testfile $srcfile \
25           {debug optimize=-O2 additional_flags=-Winline additional_flags=-std=gnu89}] } {
26     return -1
27 }
28
29 #
30 # func1 is a static inlined function that is called once.
31 # The result should be a single-location breakpoint.
32 #
33 gdb_test "break func1" \
34     "Breakpoint.*at.* file .*$srcfile, line.*"
35
36 #
37 # func2 is a non-static inlined function that is called once.
38 # The result should be a breakpoint with two locations: the
39 # out-of-line function and the single inlined instance.
40 #
41 gdb_test "break func2" \
42     "Breakpoint.*at.*func2.*\\(2 locations\\)"
43
44 #
45 # func3b is a static inlined function that is called once from
46 # within another static inlined function.  The result should be
47 # a single-location breakpoint.
48 #
49 gdb_test "break func3b" \
50     "Breakpoint.*at.* file .*$srcfile, line.*"
51
52 #
53 # func4b is a static inlined function that is called once from
54 # within a non-static inlined function.  The result should be
55 # a breakpoint with two locations: the inlined instance within
56 # the inlined call to func4a in main, and the inlined instance
57 # within the out-of-line func4a.
58 #
59 gdb_test "break func4b" \
60     "Breakpoint.*at.*func4b.*\\(2 locations\\)"
61
62 #
63 # func5b is a non-static inlined function that is called once
64 # from within a static inlined function.  The result should be a
65 # breakpoint with two locations: the out-of-line function and the
66 # inlined instance within the inlined call to func5a in main.
67 #
68 gdb_test "break func5b" \
69     "Breakpoint.*at.*func5b.*\\(2 locations\\)"
70 #
71 # func6b is a non-static inlined function that is called once from
72 # within another non-static inlined function.  The result should be
73 # a breakpoint with three locations: the out-of-line function, the
74 # inlined instance within the out-of-line func6a, and the inlined
75 # instance within the inlined call to func6a in main,
76 #
77 gdb_test "break func6b" \
78     "Breakpoint.*at.*func6b.*\\(3 locations\\)"
79
80 #
81 # func7b is a static inlined function that is called twice: once from
82 # func7a, and once from main.  The result should be a breakpoint with
83 # two locations: the inlined instance within the inlined instance of
84 # func7a, and the inlined instance within main.
85 #
86 gdb_test "break func7b" \
87     "Breakpoint.*at.*func7b.*\\(2 locations\\)"
88
89 #
90 # func8b is a non-static inlined function that is called twice: once
91 # func8a, and once from main.  The result should be a breakpoint with
92 # three locations: the out-of-line function, the inlined instance
93 # within the inlined instance of func7a, and the inlined instance
94 # within main.
95 #
96 gdb_test "break func8b" \
97     "Breakpoint.*at.*func8b.*\\(3 locations\\)"
98
99 #
100 # func1 is a static inlined function.  The result should be that no
101 # symbol is found to print.
102 #
103 gdb_test "print func1" \
104     "No symbol \"func1\" in current context."
105
106 #
107 # func2 is a non-static inlined function.  The result should be that
108 # one symbol is found to print, and that the printed symbol is called
109 # "func2".  Note that this does not cover the failure case that two
110 # symbols were found, but that gdb chose the out-of-line copy to
111 # print, but if this was failing the "print func1" test would likely
112 # fail instead.
113 #
114 gdb_test "print func2" \
115     "\\\$.* = {int \\(int\\)} .* <func2>"