]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.test-framework/gen_directive_tests
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.test-framework / gen_directive_tests
CommitLineData
395909dd
JJ
1#! /bin/bash
2
3########################################################################
4#
5# File: generate_framework_tests
6# Author: Janis Johnson
7# Date: 2004/11/02
8#
9# Generate tests of GCC's test framework. Each test has encoded in
10# its name the dg commands that are used in the test and the expected
11# result of the test, *-1.c. Each test is followed by a test ending
12# in *-2.c that is expected to pass.
13#
14# This script has evolved and could be rewritten to be more compact.
15#
16#
85ec4feb 17# Copyright (C) 2004-2018 Free Software Foundation, Inc.
395909dd
JJ
18#
19# This file is free software; you can redistribute it and/or modify
20# it under the terms of the GNU General Public License as published by
cd976c16 21# the Free Software Foundation; either version 3 of the License, or
395909dd
JJ
22# (at your option) any later version.
23#
24# This program is distributed in the hope that it will be useful,
25# but WITHOUT ANY WARRANTY; without even the implied warranty of
26# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27# GNU General Public License for more details.
28#
cd976c16
NC
29# You should have received a copy of the GNU General Public License
30# along with GCC; see the file COPYING3. If not see
31# <http://www.gnu.org/licenses/>.
395909dd
JJ
32#
33########################################################################
34
35cd $1
36
37GOOD0='*-*-*'
38GOOD1="yes"
1f732f61 39GOOD2='empty-*-* *-*-empty *-*-*'
395909dd
JJ
40BAD0='empty-empty-empty'
41BAD1="no"
1f732f61 42BAD2='empty-*-* *-empty-* *-*-empty'
395909dd
JJ
43
44# Programs used in the tests: good compile and run, bad compile, and
45# bad run.
46GOOD_PROG="int main () { return 0; }"
47BADC_PROG="int missing_body () }"
48BADR_PROG="extern void abort (void); int main () { abort (); }"
49
50# dg-do commands with a target list.
51DOT_S0="{ dg-do compile { target ${GOOD0} } }"
52DOT_S1="{ dg-do compile { target ${GOOD1} } }"
53DOT_N0="{ dg-do compile { target ${BAD0} } }"
54DOT_N1="{ dg-do compile { target ${BAD1} } }"
55
56# dg-do commands with an xfail list; the xfail list is ignored for
57# everything but "run".
58DOX_P0="{ dg-do run { xfail ${BAD0} } }"
59DOX_P1="{ dg-do run { xfail ${BAD1} } }"
60DOX_F0="{ dg-do run { xfail ${GOOD0} } }"
61DOX_F1="{ dg-do run { xfail ${GOOD1} } }"
62
63# dg-xfail-if commands.
64XIF_P0="{ dg-xfail-if \"target not matched\" { ${BAD0} } { \"-DY1\" } { \"-DY2\" } }"
65XIF_P1="{ dg-xfail-if \"target not matched\" { ${BAD0} } { \"-DY1\" } { \"-DN\" } }"
66XIF_P2="{ dg-xfail-if \"target not matched\" { ${BAD0} } { \"-DN\" } { \"-DY1\" } }"
67XIF_P3="{ dg-xfail-if \"target not matched\" { ${BAD0} } { \"-DN1\" } { \"-DN2\" } }"
68XIF_P4="{ dg-xfail-if \"exclude option matched\" { ${GOOD0} } { \"-DY1\" } { \"-DY2\" } }"
69XIF_P5="{ dg-xfail-if \"include option not matched\" { ${GOOD0} } { \"-DN\" } { \"-DY1\" } }"
70XIF_P6="{ dg-xfail-if \"include option not matched\" { ${GOOD0} } { \"-DN1\" } { \"-DN2\" } }"
71XIF_F0="{ dg-xfail-if \"all matches succeed\" { ${GOOD0} } { \"-DY1\" } { \"-DN\" } }"
72XIF_F1="{ dg-xfail-if \"all matches succeed\" { ${GOOD0} } { \"*\" } { \"-DN\" } }"
73XIF_F2="{ dg-xfail-if \"all matches succeed\" { ${GOOD0} } { \"-DY1\" } { \"\" } }"
74XIF_F3="{ dg-xfail-if \"all matches succeed\" { ${GOOD0} } { \"*\" } { \"\" } }"
75
76XIF_P7="{ dg-xfail-if \"target not matched\" { ${BAD1} } { \"-DY1\" } { \"-DY2\" } }"
77XIF_P8="{ dg-xfail-if \"target not matched\" { ${BAD1} } { \"-DY1\" } { \"-DN\" } }"
78XIF_P9="{ dg-xfail-if \"target not matched\" { ${BAD1} } { \"-DN\" } { \"-DY1\" } }"
79XIF_P10="{ dg-xfail-if \"target not matched\" { ${BAD1} } { \"-DN1\" } { \"-DN2\" } }"
80XIF_P11="{ dg-xfail-if \"exclude option matched\" { ${GOOD1} } { \"-DY1\" } { \"-DY2\" } }"
81XIF_P12="{ dg-xfail-if \"include option not matched\" { ${GOOD1} } { \"-DN\" } { \"-DY1\" } }"
82XIF_P13="{ dg-xfail-if \"include option not matched\" { ${GOOD1} } { \"-DN1\" } { \"-DN2\" } }"
83XIF_F4="{ dg-xfail-if \"all matches succeed\" { ${GOOD1} } { \"-DY1\" } { \"-DN\" } }"
84XIF_F5="{ dg-xfail-if \"all matches succeed\" { ${GOOD1} } { \"*\" } { \"-DN\" } }"
85XIF_F6="{ dg-xfail-if \"all matches succeed\" { ${GOOD1} } { \"-DY1\" } { \"\" } }"
86XIF_F7="{ dg-xfail-if \"all matches succeed\" { ${GOOD1} } { \"*\" } { \"\" } }"
87
88
89# dg-skip-if commands.
90SIF_S0="{ dg-skip-if \"target not matched\" { ${BAD0} } { \"-DY1\" } { \"-DY2\" } }"
91SIF_S1="{ dg-skip-if \"target not matched\" { ${BAD0} } { \"-DY1\" } { \"-DN\" } }"
92SIF_S2="{ dg-skip-if \"target not matched\" { ${BAD0} } { \"-DN\" } { \"-DY1\" } }"
93SIF_S3="{ dg-skip-if \"target not matched\" { ${BAD0} } { \"-DN1\" } { \"-DN2\" } }"
94SIF_S4="{ dg-skip-if \"exclude option matched\" { ${GOOD0} } { \"-DY1\" } { \"-DY2\" } }"
95SIF_S5="{ dg-skip-if \"include option not matched\" { ${GOOD0} } { \"-DN\" } { \"-DY1\" } }"
96SIF_S6="{ dg-skip-if \"include option not matched\" { ${GOOD0} } { \"-DN1\" } { \"-DN2\" } }"
97SIF_N0="{ dg-skip-if \"all matches succeed\" { ${GOOD0} } { \"-DY1\" } { \"-DN\" } }"
98SIF_N1="{ dg-skip-if \"all matches succeed\" { ${GOOD0} } { \"*\" } { \"-DN\" } }"
99SIF_N2="{ dg-skip-if \"all matches succeed\" { ${GOOD0} } { \"-DY1\" } { \"\" } }"
100SIF_N3="{ dg-skip-if \"all matches succeed\" { ${GOOD0} } { \"*\" } { \"\" } }"
101SIF_S7="{ dg-skip-if \"target not matched\" { ${BAD1} } { \"-DY1\" } { \"-DY2\" } }"
102SIF_S8="{ dg-skip-if \"target not matched\" { ${BAD1} } { \"-DY1\" } { \"-DN\" } }"
103SIF_S9="{ dg-skip-if \"target not matched\" { ${BAD1} } { \"-DN\" } { \"-DY1\" } }"
104SIF_S10="{ dg-skip-if \"target not matched\" { ${BAD1} } { \"-DN1\" } { \"-DN2\" } }"
105SIF_S11="{ dg-skip-if \"exclude option matched\" { ${GOOD1} } { \"-DY1\" } { \"-DY2\" } }"
106SIF_S12="{ dg-skip-if \"include option not matched\" { ${GOOD1} } { \"-DN\" } { \"-DY1\" } }"
107SIF_S13="{ dg-skip-if \"include option not matched\" { ${GOOD1} } { \"-DN1\" } { \"-DN2\" } }"
108SIF_N4="{ dg-skip-if \"all matches succeed\" { ${GOOD1} } { \"-DY1\" } { \"-DN\" } }"
109SIF_N5="{ dg-skip-if \"all matches succeed\" { ${GOOD1} } { \"*\" } { \"-DN\" } }"
110SIF_N6="{ dg-skip-if \"all matches succeed\" { ${GOOD1} } { \"-DY1\" } { \"\" } }"
111SIF_N7="{ dg-skip-if \"all matches succeed\" { ${GOOD1} } { \"*\" } { \"\" } }"
112
113# dg-require-* commands, using procedures defined for this set of tests.
114REQ_S0="{ dg-require-true \"\" }" # do not skip the test
115REQ_N0="{ dg-require-false \"\" }" # skip the test
116
117# scan-assembler-not, which is hoped to be representative of commands
118# used with dg-final, with a target list.
119SAT_N0="{ dg-final { scan-assembler-not \"unexpected gargage\" { target ${BAD0} } } }"
120SAT_N1="{ dg-final { scan-assembler-not \"unexpected gargage\" { target ${BAD1} } } }"
121SAT_S0="{ dg-final { scan-assembler-not \"unexpected gargage\" { target ${GOOD0} } } }"
122SAT_S1="{ dg-final { scan-assembler-not \"unexpected gargage\" { target ${GOOD1} } } }"
123
124# scan-assembler-not, which is hoped to be representative of commands
125# used with dg-final, with an xfail list.
126SAX_P0="{ dg-final { scan-assembler-not \"unexpected gargage\" { xfail ${BAD0} } } }"
127SAX_P1="{ dg-final { scan-assembler-not \"unexpected gargage\" { xfail ${BAD1} } } }"
128SAX_F0="{ dg-final { scan-assembler-not \"unexpected gargage\" { xfail ${GOOD0} } } }"
129SAX_F1="{ dg-final { scan-assembler-not \"unexpected gargage\" { xfail ${GOOD1} } } }"
130
131KIND_LIST=""
132
133# Expected result of the *-1.c test, encoded into the file name.
134EXP_PASS="exp-P"
135EXP_XPASS="exp-XP"
136EXP_SKIP="exp-U"
137EXP_FAIL="exp-F"
138EXP_XFAIL="exp-XF"
139
140get_list() {
141 KIND=$1
142 case $KIND in
143 "dots") KIND_LIST="dots0 dots1";;
144 "dotn") KIND_LIST="dotn0 dotn1";;
145 "doxp") KIND_LIST="doxp0 doxp1";;
146 "doxf") KIND_LIST="doxf0 doxf1";;
147 "sifs") KIND_LIST="sifs0 sifs1 sifs2 sifs3 sifs4 sifs5 sifs6 sifs7 sifs8 sifs9 sifs10 sifs11 sifs12 sifs13";;
148 "sifn") KIND_LIST="sifn0 sifn1 sifn2 sifn3 sifn4 sifn5 sifn6 sifn7";;
149 "xifp") KIND_LIST="xifp0 xifp1 xifp2 xifp3 xifp4 xifp5 xifp6 xifp7 xifp8 xifp9 xifp10 xifp11 xifp12 xifp13";;
150 "xiff") KIND_LIST="xiff0 xiff1 xiff2 xiff3 xiff4 xiff5 xiff6 xiff7";;
151 "sats") KIND_LIST="sats0 sats1";;
152 "satn") KIND_LIST="satn0 satn1";;
153 "saxp") KIND_LIST="saxp0 saxp1";;
154 "saxf") KIND_LIST="saxf0 saxf1";;
155 "reqs") KIND_LIST="reqs0";;
156 "reqn") KIND_LIST="reqn0";;
157 *) echo "oops: $KIND"; exit 1;;
158 esac
159}
160
161cmd() {
162 KIND=$1
163 FILE=$2
164
165 case $KIND in
166 "dots") echo '/*' "${DOT_S0}" '*/' >> $FILE;;
167 "dots0") echo '/*' "${DOT_S0}" '*/' >> $FILE;;
168 "dots1") echo '/*' "${DOT_S1}" '*/' >> $FILE;;
169 "dots2") echo '/*' "${DOT_S2}" '*/' >> $FILE;;
170 "dots3") echo '/*' "${DOT_S3}" '*/' >> $FILE;;
171 "dots4") echo '/*' "${DOT_S4}" '*/' >> $FILE;;
172 "dotn") echo '/*' "${DOT_N0}" '*/' >> $FILE;;
173 "dotn0") echo '/*' "${DOT_N0}" '*/' >> $FILE;;
174 "dotn1") echo '/*' "${DOT_N1}" '*/' >> $FILE;;
175 "dotn2") echo '/*' "${DOT_N2}" '*/' >> $FILE;;
176 "dotn3") echo '/*' "${DOT_N3}" '*/' >> $FILE;;
177 "dotn4") echo '/*' "${DOT_N4}" '*/' >> $FILE;;
178 "doxp") echo '/*' "${DOX_P0}" '*/' >> $FILE;;
179 "doxp0") echo '/*' "${DOX_P0}" '*/' >> $FILE;;
180 "doxp1") echo '/*' "${DOX_P1}" '*/' >> $FILE;;
181 "doxp2") echo '/*' "${DOX_P2}" '*/' >> $FILE;;
182 "doxp3") echo '/*' "${DOX_P3}" '*/' >> $FILE;;
183 "doxp4") echo '/*' "${DOX_P4}" '*/' >> $FILE;;
184 "doxf") echo '/*' "${DOX_F0}" '*/' >> $FILE;;
185 "doxf0") echo '/*' "${DOX_F0}" '*/' >> $FILE;;
186 "doxf1") echo '/*' "${DOX_F1}" '*/' >> $FILE;;
187 "doxf2") echo '/*' "${DOX_F2}" '*/' >> $FILE;;
188 "doxf3") echo '/*' "${DOX_F3}" '*/' >> $FILE;;
189 "doxf4") echo '/*' "${DOX_F4}" '*/' >> $FILE;;
190 "sifs") echo '/*' "${SIF_S0}" '*/' >> $FILE;;
191 "sifs0") echo '/*' "${SIF_S0}" '*/' >> $FILE;;
192 "sifs1") echo '/*' "${SIF_S1}" '*/' >> $FILE;;
193 "sifs2") echo '/*' "${SIF_S2}" '*/' >> $FILE;;
194 "sifs3") echo '/*' "${SIF_S3}" '*/' >> $FILE;;
195 "sifs4") echo '/*' "${SIF_S4}" '*/' >> $FILE;;
196 "sifs5") echo '/*' "${SIF_S5}" '*/' >> $FILE;;
197 "sifs6") echo '/*' "${SIF_S6}" '*/' >> $FILE;;
198 "sifs7") echo '/*' "${SIF_S7}" '*/' >> $FILE;;
199 "sifs8") echo '/*' "${SIF_S8}" '*/' >> $FILE;;
200 "sifs9") echo '/*' "${SIF_S9}" '*/' >> $FILE;;
201 "sifs10") echo '/*' "${SIF_S10}" '*/' >> $FILE;;
202 "sifs11") echo '/*' "${SIF_S11}" '*/' >> $FILE;;
203 "sifs12") echo '/*' "${SIF_S12}" '*/' >> $FILE;;
204 "sifs13") echo '/*' "${SIF_S13}" '*/' >> $FILE;;
205 "sifn") echo '/*' "${SIF_N0}" '*/' >> $FILE;;
206 "sifn0") echo '/*' "${SIF_N0}" '*/' >> $FILE;;
207 "sifn1") echo '/*' "${SIF_N1}" '*/' >> $FILE;;
208 "sifn2") echo '/*' "${SIF_N2}" '*/' >> $FILE;;
209 "sifn3") echo '/*' "${SIF_N3}" '*/' >> $FILE;;
210 "sifn4") echo '/*' "${SIF_N4}" '*/' >> $FILE;;
211 "sifn5") echo '/*' "${SIF_N5}" '*/' >> $FILE;;
212 "sifn6") echo '/*' "${SIF_N6}" '*/' >> $FILE;;
213 "sifn7") echo '/*' "${SIF_N7}" '*/' >> $FILE;;
214 "xifp") echo '/*' "${XIF_P0}" '*/' >> $FILE;;
215 "xifp0") echo '/*' "${XIF_P0}" '*/' >> $FILE;;
216 "xifp1") echo '/*' "${XIF_P1}" '*/' >> $FILE;;
217 "xifp2") echo '/*' "${XIF_P2}" '*/' >> $FILE;;
218 "xifp3") echo '/*' "${XIF_P3}" '*/' >> $FILE;;
219 "xifp4") echo '/*' "${XIF_P4}" '*/' >> $FILE;;
220 "xifp5") echo '/*' "${XIF_P5}" '*/' >> $FILE;;
221 "xifp6") echo '/*' "${XIF_P6}" '*/' >> $FILE;;
222 "xifp7") echo '/*' "${XIF_P7}" '*/' >> $FILE;;
223 "xifp8") echo '/*' "${XIF_P8}" '*/' >> $FILE;;
224 "xifp9") echo '/*' "${XIF_P9}" '*/' >> $FILE;;
225 "xifp10") echo '/*' "${XIF_P10}" '*/' >> $FILE;;
226 "xifp11") echo '/*' "${XIF_P11}" '*/' >> $FILE;;
227 "xifp12") echo '/*' "${XIF_P12}" '*/' >> $FILE;;
228 "xifp13") echo '/*' "${XIF_P13}" '*/' >> $FILE;;
229 "xiff") echo '/*' "${XIF_F0}" '*/' >> $FILE;;
230 "xiff0") echo '/*' "${XIF_F0}" '*/' >> $FILE;;
231 "xiff1") echo '/*' "${XIF_F1}" '*/' >> $FILE;;
232 "xiff2") echo '/*' "${XIF_F2}" '*/' >> $FILE;;
233 "xiff3") echo '/*' "${XIF_F3}" '*/' >> $FILE;;
234 "xiff4") echo '/*' "${XIF_F4}" '*/' >> $FILE;;
235 "xiff5") echo '/*' "${XIF_F5}" '*/' >> $FILE;;
236 "xiff6") echo '/*' "${XIF_F6}" '*/' >> $FILE;;
237 "xiff7") echo '/*' "${XIF_F7}" '*/' >> $FILE;;
238 "satn") echo '/*' "${SAT_N0}" '*/' >> $FILE;;
239 "satn0") echo '/*' "${SAT_N0}" '*/' >> $FILE;;
240 "satn1") echo '/*' "${SAT_N1}" '*/' >> $FILE;;
241 "satn2") echo '/*' "${SAT_N2}" '*/' >> $FILE;;
242 "satn3") echo '/*' "${SAT_N3}" '*/' >> $FILE;;
243 "satn4") echo '/*' "${SAT_N4}" '*/' >> $FILE;;
244 "sats") echo '/*' "${SAT_S0}" '*/' >> $FILE;;
245 "sats0") echo '/*' "${SAT_S0}" '*/' >> $FILE;;
246 "sats1") echo '/*' "${SAT_S1}" '*/' >> $FILE;;
247 "sats2") echo '/*' "${SAT_S2}" '*/' >> $FILE;;
248 "sats3") echo '/*' "${SAT_S3}" '*/' >> $FILE;;
249 "sats4") echo '/*' "${SAT_S4}" '*/' >> $FILE;;
250 "saxp") echo '/*' "${SAX_P0}" '*/' >> $FILE;;
251 "saxp0") echo '/*' "${SAX_P0}" '*/' >> $FILE;;
252 "saxp1") echo '/*' "${SAX_P1}" '*/' >> $FILE;;
253 "saxp2") echo '/*' "${SAX_P2}" '*/' >> $FILE;;
254 "saxp3") echo '/*' "${SAX_P3}" '*/' >> $FILE;;
255 "saxp4") echo '/*' "${SAX_P4}" '*/' >> $FILE;;
256 "saxf") echo '/*' "${SAX_F0}" '*/' >> $FILE;;
257 "saxf0") echo '/*' "${SAX_F0}" '*/' >> $FILE;;
258 "saxf1") echo '/*' "${SAX_F1}" '*/' >> $FILE;;
259 "saxf2") echo '/*' "${SAX_F2}" '*/' >> $FILE;;
260 "saxf3") echo '/*' "${SAX_F3}" '*/' >> $FILE;;
261 "saxf4") echo '/*' "${SAX_F4}" '*/' >> $FILE;;
262 "reqs") echo '/*' "${REQ_S0}" '*/' >> $FILE;;
263 "reqs0") echo '/*' "${REQ_S0}" '*/' >> $FILE;;
264 "reqn") echo '/*' "${REQ_N0}" '*/' >> $FILE;;
265 "reqn0") echo '/*' "${REQ_N0}" '*/' >> $FILE;;
266 *) echo "oops: $KIND"; exit 1;;
267 esac
268}
269
270# Generate a test using a single dg- command. If requested, generate a
271# second version that will fail.
272one() {
273 KIND=$1
274 EXP=$2
275 FAIL_VERSION=$3
276
277 NAME=${KIND}-${EXP}
278 FILE1=${NAME}-1.c
279 FILE2=${NAME}-2.c
280 rm -f $FILE1
281 touch $FILE1
282 cmd $KIND $FILE1
283 echo "${GOOD_PROG}" >> $FILE1
284 echo "${GOOD_PROG}" > $FILE2
285
286 if [ "${FAIL_VERSION}" == "yes" ]; then
287 if [ "${EXP}" == "${EXP_PASS}" ]; then
288 NAME=${KIND}-${EXP_FAIL}
289 else
290 NAME=${KIND}-${EXP_XFAIL}
291 fi
292
293 FILE1=${NAME}-1.c
294 FILE2=${NAME}-2.c
295 rm -f $FILE1
296 touch $FILE1
297 cmd $KIND $FILE1
298 case $KIND in
299 dox*) echo "${BADR_PROG}" >> $FILE1;;
300 *) echo "${BADC_PROG}" >> $FILE1;;
301 esac
302 echo "${GOOD_PROG}" > $FILE2
303 fi
304}
305
306# Generate a test using two dg- commands. If requested, generate a
307# second version that will fail.
308two() {
309 KIND1=$1
310 KIND2=$2
311 EXP=$3
312 FAIL_VERSION=$4
313
314 NAME=${KIND1}-${KIND2}-${EXP}
315 FILE1=${NAME}-1.c
316 FILE2=${NAME}-2.c
317
318 rm -f $FILE1
319 touch $FILE1
320 cmd $KIND1 $FILE1
321 cmd $KIND2 $FILE1
322 echo "${GOOD_PROG}" >> $FILE1
323 echo "${GOOD_PROG}" > $FILE2
324
325 if [ "${FAIL_VERSION}" == "yes" ]; then
326 if [ "${EXP}" == "${EXP_PASS}" ]; then
327 NAME=${KIND1}-${KIND2}-${EXP_FAIL}
328 else
329 NAME=${KIND1}-${KIND2}-${EXP_XFAIL}
330 fi
331
332 FILE1=${NAME}-1.c
333 FILE2=${NAME}-2.c
334 rm -f $FILE1
335 touch $FILE1
336 cmd $KIND1 $FILE1
337 cmd $KIND2 $FILE1
338 # dg-do with an xfail list is only used as the first command.
339 case $KIND1 in
340 dox*) echo "${BADR_PROG}" >> $FILE1;;
341 *) echo "${BADC_PROG}" >> $FILE1;;
342 esac
343 echo "${GOOD_PROG}" > $FILE2
344 fi
345}
346
347# Generate a test using three dg- commands. If requested generate a
348# second version that will fail.
349three() {
350 KIND1=$1
351 KIND2=$2
352 KIND3=$3
353 EXP=$4
354 FAIL_VERSION=$5
355
356 NAME=${KIND1}-${KIND2}-${KIND3}-${EXP}
357 FILE1=${NAME}-1.c
358 FILE2=${NAME}-2.c
359 rm -f $FILE1
360 touch $FILE1
361 cmd $KIND1 $FILE1
362 cmd $KIND2 $FILE1
363 cmd $KIND3 $FILE1
364 echo "${GOOD_PROG}" >> $FILE1
365 echo "${GOOD_PROG}" > $FILE2
366
367 if [ "${FAIL_VERSION}" == "${yes}" ]; then
368 if [ "${EXP}" == "${EXP_PASS}" ]; then
369 NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_FAIL}
370 else
371 NAME=${KIND1}-${KIND2}-${KIND3}-${EXP_XFAIL}
372 fi
373
374 FILE1=${NAME}-1.c
375 FILE2=${NAME}-2.c
376 rm -f $FILE1
377 touch $FILE1
378 cmd $KIND1 $FILE1
379 cmd $KIND2 $FILE1
380 cmd $KIND3 $FILE1
381 # dg-do with an xfail list is only used as the first command.
382 case $KIND1 in
383 dox*) echo "${BADR_PROG}" >> $FILE1;;
384 *) echo "${BADC_PROG}" >> $FILE1;;
385 esac
386 echo "${GOOD_PROG}" > $FILE2
387 fi
388}
389
390# Generate tests using one dg- command. Generate a test for each variant
391# of KIND.
392one_all() {
393 KIND=$1
394 EXP=$2
395 FAIL_VERSION=$3
396
397 get_list $KIND
398 for k in $KIND_LIST; do
399 one $k $EXP $FAIL_VERSION
400 done
401}
402
403# Generate tests using two dg- commands. For each KIND, generate
404# a test for each of its variants.
405two_all() {
406 KIND1=$1
407 KIND2=$2
408 EXP=$3
409 FAIL_VERSION=$4
410
411 get_list $KIND1
412 KIND_LIST1="$KIND_LIST"
413 get_list $KIND2
414 KIND_LIST2="$KIND_LIST"
415 for k1 in $KIND_LIST1; do
416 for k2 in $KIND_LIST2; do
417 two $k1 $k2 $EXP $FAIL_VERSION
418 done
419 done
420}
421
422# Generate tests using three dg- commands. For each KIND, generate
423# a test for each of its variants.
424three_all() {
425 KIND1=$1
426 KIND2=$2
427 KIND3=$3
428 EXP=$4
429 FAIL_VERSION=$5
430
431 get_list $KIND1
432 KIND_LIST1="$KIND_LIST"
433 get_list $KIND2
434 KIND_LIST2="$KIND_LIST"
435 get_list $KIND3
436 KIND_LIST3="$KIND_LIST"
437 for k1 in $KIND_LIST1; do
438 for k2 in $KIND_LIST2; do
439 for k3 in $KIND_LIST3; do
440 three $k1 $k2 $k3 $EXP $FAIL_VERSION
441 done
442 done
443 done
444}
445
1f732f61
JJ
446# Generate a test that uses a dg-do directive with a selector expression.
447dgdo_progs() {
448 WHAT=$1
449 KIND=$2
450 PROG="$3"
451 NAME="$4"
452 XPR="$5"
453
454 FILE1=${NAME}-1.c
455 FILE2=${NAME}-2.c
456 rm -f $FILE1
457 touch $FILE1
458 echo '/* { dg-do' $WHAT '{' $KIND "$XPR" '} } */' >> $FILE1
459 echo "${PROG}" >> $FILE1
460 echo "${GOOD_PROG}" > $FILE2
461}
462
463# Use various selector-expressions that evaluate to TRUE in dg-do directives.
464selector_good() {
465 NUM=101
466 for xpr in \
467 "$GOOD0" \
468 "$GOOD1" \
469 "$GOOD2" \
470 "{ ! $BAD0 }" \
471 "{ ! $BAD1 }" \
472 "{ ! { $BAD2 } }" \
473 "{ ! \"${BAD2}\" }" \
474 "{ $GOOD1 || $GOOD0 }" \
475 "{ $BAD1 || $GOOD0 }" \
476 "{ $GOOD0 && $GOOD1 }" \
477 "{ $BAD1 || { \"${GOOD2}\" && $GOOD1 } }" \
478 "{ { $BAD0 || $GOOD0 } && $GOOD0 }" \
479 "{ $GOOD1 && { \"${GOOD2}\" || $BAD1 } }" \
480 "{ \"${GOOD2}\" && { $GOOD1 || $BAD1 } }"
481 do
482 dgdo_progs compile target "$GOOD_PROG" "dots${NUM}-exp-P" "$xpr"
483 dgdo_progs compile target "$BADC_PROG" "dots${NUM}-exp-F" "$xpr"
484 dgdo_progs run xfail "$GOOD_PROG" "doxf${NUM}-exp-XP" "$xpr"
485 dgdo_progs run xfail "$BADR_PROG" "doxf${NUM}-exp-XF" "$xpr"
486 let NUM=NUM+1
487 done
488}
489
490# Use various selector-expressions that evaluate to FALSE in dg-do directives.
491selector_bad() {
492 NUM=101
493 for xpr in \
494 "$BAD0" \
495 "$BAD1" \
496 "$BAD2" \
497 "{ ! $GOOD0 }" \
498 "{ ! $GOOD1 }" \
499 "{ ! { $GOOD2 } }" \
500 "{ ! \"${GOOD2}\" }" \
501 "{ $BAD1 || $BAD0 }" \
502 "{ $BAD0 && $GOOD1 }" \
503 "{ $GOOD1 && $BAD0 }" \
504 "{ $BAD1 || { $GOOD1 && $BAD0 } }" \
505 "{ { $GOOD1 || $BAD1 } && $BAD0 }" \
506 "{ $BAD1 || { \"${BAD2}\" && $GOOD1 } }" \
507 "{ \"${BAD2}\" && { $GOOD1 || $BAD1 } }"
508 do
509 dgdo_progs compile target "$GOOD_PROG" "dotn${NUM}-exp-U" "$xpr"
510 dgdo_progs run xfail "$GOOD_PROG" "doxp${NUM}-exp-P" "$xpr"
511 dgdo_progs run xfail "$BADR_PROG" "doxp${NUM}-exp-F" "$xpr"
512 let NUM=NUM+1
513 done
514}
515
516# Write a test whose directive is too long and messy to do as one string.
517deep_progs() {
518 PROG="$1"
519 NAME=$2
520 CMD1="$3"
521 CMD2="$4"
522 CMD3="$5"
523
524 FILE1=${NAME}-1.c
525 FILE2=${NAME}-2.c
526 rm -f $FILE1
527 touch $FILE1
528 echo "$CMD1" "$CMD2" "$CMD3" > $FILE1
529 echo "$PROG" >> $FILE1
530 echo "$GOOD_PROG" > $FILE2
531}
532
533# Use nested expressions in various test directives.
534selector_deep() {
535 GOODXPR="{ \"${GOOD2}\" && { ! { $BAD0 || $BAD1 } } }"
536 BADXPR="{ ! { \"${GOOD2}\" || { $GOOD1 && $BAD1 } } }"
537 NUM=100
538 dgdo_progs compile target "$GOOD_PROG" "dots${NUM}-exp-P" "$GOODXPR"
539 dgdo_progs compile target "$GOOD_PROG" "dotn${NUM}-exp-U" "$BADXPR"
540
541 deep_progs "$BADC_PROG" "xiff-100-exp-XF" \
4f4b0ab8 542 '/* { dg-xfail-if "match" { ' "{ $GOODXPR }" ' } } */'
1f732f61 543 deep_progs "$GOOD_PROG" "xifp-100-exp-P" \
4f4b0ab8 544 '/* { dg-xfail-if "no match" { ' "{ $BADXPR }" ' } } */'
1f732f61 545 deep_progs "$BADC_PROG" "xifn-100-exp-U" \
4f4b0ab8 546 '/* { dg-skip-if "match" { ' "{ $GOODXPR }" ' } } */'
1f732f61 547 deep_progs "$GOOD_PROG" "xifs-100-exp-P" \
4f4b0ab8 548 '/* { dg-skip-if "match" { ' "{ $BADXPR }" ' } } */'
1f732f61
JJ
549 deep_progs "$GOOD_PROG" "satn-100-exp-P" \
550 '/* { dg-final { scan-assembler-not "unexpected garbage" { target ' \
551 "$GOODXPR" ' } } } */'
552 deep_progs "$GOOD_PROG" "satn-100-exp-U" \
553 '/* { dg-final { scan-assembler-not "unexpected garbage" { target ' \
554 "$BADXPR" ' } } } */'
555 deep_progs "$GOOD_PROG" "satf-100-exp-XP" \
556 '/* { dg-final { scan-assembler-not "unexpected garbage" { xfail ' \
557 "$GOODXPR" ' } } } */'
558 deep_progs "$GOOD_PROG" "satp-100-exp-P" \
559 '/* { dg-final { scan-assembler-not "unexpected garbage" { xfail ' \
560 "$BADXPR" ' } } } */'
561}
562
563selector_good
564selector_bad
565selector_deep
566
395909dd
JJ
567one_all saxp $EXP_PASS no
568one_all saxf $EXP_XPASS no
569one_all sats $EXP_PASS no
570one_all satn $EXP_SKIP no
571one_all dots $EXP_PASS yes
572one_all dotn $EXP_SKIP no
573one_all doxp $EXP_PASS yes
574one_all doxf $EXP_XPASS yes
575one_all sifs $EXP_PASS yes
576one_all sifn $EXP_SKIP no
577one_all xifp $EXP_PASS yes
578one_all xiff $EXP_XPASS yes
579one_all reqs $EXP_PASS yes
580one_all reqn $EXP_SKIP no
581
582two_all dots xifp $EXP_PASS yes
583two_all dots xiff $EXP_XPASS yes
584two_all dots sifs $EXP_PASS yes
585two_all dots sifn $EXP_SKIP no
586two_all dotn xifp $EXP_SKIP no
587two_all dotn sifs $EXP_SKIP no
588two_all dotn sifn $EXP_SKIP no
589two_all dotn xiff $EXP_SKIP no
590two_all dots reqs $EXP_PASS yes
591two_all dots reqn $EXP_SKIP no
592two_all dotn reqs $EXP_SKIP no
593two_all dotn reqn $EXP_SKIP no
594
595two_all doxp xifp $EXP_PASS yes
596two_all doxp xiff $EXP_PASS yes # dg-xfail-if applies to compile, not run
597two_all doxp sifs $EXP_PASS yes
598two_all doxp sifn $EXP_SKIP no
599two_all doxf xifp $EXP_XPASS yes
600two_all doxf xiff $EXP_XPASS yes
601two_all doxf sifs $EXP_XPASS yes
602two_all doxf sifn $EXP_SKIP no
603
604two_all doxp reqs $EXP_PASS yes
605two_all doxp reqn $EXP_SKIP no
606two_all doxf reqs $EXP_XPASS yes
607two_all doxf reqn $EXP_SKIP no
608
609two_all reqs xifp $EXP_PASS yes
610two_all reqs xiff $EXP_XPASS yes
611two_all reqs sifs $EXP_PASS yes
612two_all reqs sifn $EXP_SKIP no
613two_all reqn xifp $EXP_SKIP no
614two_all reqn xiff $EXP_SKIP no
615two_all reqn sifs $EXP_SKIP no
616two_all reqn sifn $EXP_SKIP no
617
618two_all xifp reqs $EXP_PASS yes
619two_all xiff reqs $EXP_XPASS yes
620two_all sifs reqs $EXP_PASS yes
621two_all sifn reqs $EXP_SKIP no
622two_all xifp reqn $EXP_SKIP no
623two_all xiff reqn $EXP_SKIP no
624two_all sifs reqn $EXP_SKIP no
625two_all sifn reqn $EXP_SKIP no
626
627three_all dots reqs xifp $EXP_PASS yes
628three_all dots reqs xiff $EXP_XPASS yes
629three_all dots reqs sifs $EXP_PASS yes
630three_all dots reqs sifn $EXP_SKIP no
631three_all dots reqn xifp $EXP_SKIP no
632three_all dots reqn xiff $EXP_SKIP no
633three_all dots reqn sifs $EXP_SKIP no
634three_all dots reqn sifn $EXP_SKIP no
635three_all dotn reqs xifp $EXP_SKIP no
636three_all dotn reqs xiff $EXP_SKIP no
637three_all dotn reqs sifs $EXP_SKIP no
638three_all dotn reqs sifn $EXP_SKIP no
639three_all dotn reqn xifp $EXP_SKIP no
640three_all dotn reqn xiff $EXP_SKIP no
641three_all dotn reqn sifs $EXP_SKIP no
642three_all dotn reqn sifn $EXP_SKIP no
643#
644three_all dots xifp reqs $EXP_PASS yes
645three_all dots xiff reqs $EXP_XPASS yes
646three_all dots sifs reqs $EXP_PASS yes
647three_all dots sifn reqs $EXP_SKIP no
648three_all dots xifp reqn $EXP_SKIP no
649three_all dots xiff reqn $EXP_SKIP no
650three_all dots sifs reqn $EXP_SKIP no
651three_all dots sifn reqn $EXP_SKIP no
652three_all dotn xifp reqs $EXP_SKIP no
653three_all dotn xiff reqs $EXP_SKIP no
654three_all dotn sifs reqs $EXP_SKIP no
655three_all dotn sifn reqs $EXP_SKIP no
656three_all dotn xifp reqn $EXP_SKIP no
657three_all dotn xiff reqn $EXP_SKIP no
658three_all dotn sifs reqn $EXP_SKIP no
659three_all dotn sifn reqn $EXP_SKIP no
660
661three_all doxp reqs xifp $EXP_PASS yes
662three_all doxp reqs xiff $EXP_PASS yes # dg-xfail-if applies to compile, not run
663three_all doxp reqs sifs $EXP_PASS yes
664three_all doxp reqs sifn $EXP_SKIP no
665three_all doxp reqn xifp $EXP_SKIP no
666three_all doxp reqn xiff $EXP_SKIP no
667three_all doxp reqn sifs $EXP_SKIP no
668three_all doxp reqn sifn $EXP_SKIP no
669three_all doxf reqs xifp $EXP_XPASS yes
670three_all doxf reqs xiff $EXP_XPASS yes
671three_all doxf reqs sifs $EXP_XPASS yes
672three_all doxf reqs sifn $EXP_SKIP no
673three_all doxf reqn xifp $EXP_SKIP no
674three_all doxf reqn xiff $EXP_SKIP no
675three_all doxf reqn sifs $EXP_SKIP no
676three_all doxf reqn sifn $EXP_SKIP no
677
678three_all doxp xifp reqs $EXP_PASS yes
679three_all doxp xiff reqs $EXP_PASS yes # dg-xfail-if applies to compile, not run
680three_all doxp sifs reqs $EXP_PASS yes
681three_all doxp sifn reqs $EXP_SKIP no
682three_all doxp xifp reqn $EXP_SKIP no
683three_all doxp xiff reqn $EXP_SKIP no
684three_all doxp sifs reqn $EXP_SKIP no
685three_all doxp sifn reqn $EXP_SKIP no
686three_all doxf xifp reqs $EXP_XPASS yes
687three_all doxf xiff reqs $EXP_XPASS yes
688three_all doxf sifs reqs $EXP_XPASS yes
689three_all doxf sifn reqs $EXP_SKIP no
690three_all doxf xifp reqn $EXP_SKIP no
691three_all doxf xiff reqn $EXP_SKIP no
692three_all doxf sifs reqn $EXP_SKIP no
693three_all doxf sifn reqn $EXP_SKIP no