PR c++/81917 - ICE with void_t and partial specialization.
[official-gcc.git] / gcc / testsuite / lib / mike-g++.exp
blob69ceb56c42172aea6dc9b0766f929b5749743eee
1 # Copyright (C) 1988-2018 Free Software Foundation, Inc.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
17 # This file was written by Mike Stump <mrs@cygnus.com>
19 load_lib target-utils.exp
22 # mike_cleanup -- remove any files that are created by the testcase
24 proc mike_cleanup { src_code output_file assembly_file } {
25 remote_file build delete $output_file $assembly_file
29 # prebase -- sets up a Mike Stump (mrs@cygnus.com) style G++ test
31 proc prebase { } {
32 global compiler_output
33 global not_compiler_output
34 global compiler_result
35 global not_compiler_result
36 global program_output
37 global groups
38 global run
39 global actions
40 global target_regexp
42 set compiler_output "^$"
43 set not_compiler_output ".*Internal compiler error.*"
44 set compiler_result ""
45 set not_compiler_result ""
46 set program_output ".*PASS.*"
47 set groups {}
48 set run no
49 set actions assemble
50 set target_regexp ".*"
54 # run the test
56 proc postbase { src_code run groups args } {
57 global verbose
58 global srcdir
59 global subdir
60 global not_compiler_output
61 global compiler_output
62 global compiler_result
63 global not_compiler_result
64 global program_output
65 global actions
66 global target_regexp
67 global host_triplet
68 global target_triplet
69 global tool
70 global tmpdir
71 global objdir
72 global base_dir
74 if ![regexp $target_regexp $target_triplet] {
75 unsupported $subdir/$src_code
76 return
79 if { [llength $args] > 0 } {
80 set comp_options [lindex $args 0]
81 } else {
82 set comp_options ""
85 set fail_message $subdir/$src_code
86 set pass_message $subdir/$src_code
88 if [info exists GROUP] {
89 if {[lsearch $groups $GROUP] == -1} {
90 return
94 if [string match $run yes] {
95 set actions run
98 set output_file "$tmpdir/[file tail [file rootname $src_code]]"
99 set assembly_file "$output_file"
100 append assembly_file ".S"
102 set compile_type "none"
104 case $actions {
105 compile
107 set compile_type "assembly"
108 set output_file $assembly_file
110 assemble
112 set compile_type "object"
113 append output_file ".o"
115 link
117 set compile_type "executable"
118 append output_file ".exe"
122 set compile_type "executable"
123 append output_file ".exe"
124 set run yes
126 default
128 set output_file ""
129 set compile_type "none"
133 set src_file "$srcdir/$subdir/$src_code"
134 set options ""
136 if { $comp_options != "" } {
137 lappend options "additional_flags=$comp_options"
140 if ![ishost "*-dos-*"] {
141 lappend options "libs=-lstdc++ -lg++"
142 } else {
143 lappend options "libs=-lstdcxx -lgxx"
146 set comp_output [g++_target_compile $src_file $output_file $compile_type $options]
148 set pass no
150 # Delete things like "ld.so warning" messages.
151 set comp_output [prune_warnings $comp_output]
153 if [regexp -- $not_compiler_output $comp_output] {
154 if { $verbose > 1 } {
155 send_user "\nChecking:\n$not_compiler_output\nto make sure it does not match:\n$comp_output\nbut it does.\n\n"
156 } else {
157 send_log "\nCompiler output:\n$comp_output\n\n"
159 fail $fail_message
160 # The framework doesn't like to see any error remnants,
161 # so remove them.
162 uplevel {
163 if [info exists errorInfo] {
164 unset errorInfo
167 mike_cleanup $src_code $output_file $assembly_file
168 return
171 # remove any leftover CRs.
172 regsub -all -- "\r" $comp_output "" comp_output
174 regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $comp_output "" comp_output
175 regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $comp_output "" comp_output
177 set unsupported_message [${tool}_check_unsupported_p $comp_output]
178 if { $unsupported_message != "" } {
179 unsupported "$subdir/$src_code: $unsupported_message"
180 mike_cleanup $src_code $output_file $assembly_file
181 return
184 if { $verbose > 1 } {
185 send_user "\nChecking:\n$compiler_output\nto see if it matches:\n$comp_output\n"
186 } else {
187 send_log "\nCompiler output:\n$comp_output\n\n"
189 if [regexp -- $compiler_output $comp_output] {
190 if { $verbose > 1 } {
191 send_user "Yes, it matches.\n\n"
193 set pass yes
194 if [file exists [file rootname [file tail $src_code]].s] {
195 set fd [open [file rootname [file tail $src_code]].s r]
196 set dot_s [read $fd]
197 close $fd
198 if { $compiler_result != "" } {
199 verbose "Checking .s file for $compiler_result" 2
200 if [regexp -- $compiler_result $dot_s] {
201 verbose "Yes, it matches." 2
202 } else {
203 verbose "Nope, doesn't match." 2
204 verbose $dot_s 4
205 set pass no
208 if { $not_compiler_result != "" } {
209 verbose "Checking .s file for not $not_compiler_result" 2
210 if ![regexp -- $not_compiler_result $dot_s] {
211 verbose "Nope, not found (that's good)." 2
212 } else {
213 verbose "Uh oh, it was found." 2
214 verbose $dot_s 4
215 set pass no
219 if [string match $run yes] {
220 set result [g++_load $output_file]
221 set status [lindex $result 0]
222 set output [lindex $result 1]
224 if { $status == -1 } {
225 mike_cleanup $src_code $output_file $assembly_file
226 return
228 if { $verbose > 1 } {
229 send_user "Checking:\n$program_output\nto see if it matches:\n$output\n\n"
231 if ![regexp -- $program_output $output] {
232 set pass no
233 if { $verbose > 1 } {
234 send_user "Nope, does not match.\n\n"
236 } else {
237 if { $verbose > 1 } {
238 send_user "Yes, it matches.\n\n"
242 } else {
243 if { $verbose > 1 } {
244 send_user "Nope, does not match.\n\n"
248 if [string match $pass "yes"] {
249 pass $pass_message
250 } else {
251 fail $fail_message
254 # The framework doesn't like to see any error remnants,
255 # so remove them.
256 uplevel {
257 if [info exists errorInfo] {
258 unset errorInfo
262 mike_cleanup $src_code $output_file $assembly_file