| 1 |
# GCC Objective-C testsuite that uses the `dg.exp' driver. |
| 2 |
# Copyright (C) 1997-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
# This program is free software; you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation; either version 3 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with GCC; see the file COPYING3. If not see |
| 16 |
# <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
# Load support procs. |
| 19 |
load_lib objc-dg.exp |
| 20 |
|
| 21 |
# If a testcase doesn't have special options, use these. |
| 22 |
global DEFAULT_CFLAGS |
| 23 |
if ![info exists DEFAULT_CFLAGS] then { |
| 24 |
set DEFAULT_CFLAGS "" |
| 25 |
} |
| 26 |
|
| 27 |
# Initialize `dg'. |
| 28 |
dg-init |
| 29 |
|
| 30 |
# TODO: All these testcases compile and link two Objective-C modules. |
| 31 |
# Remove code duplication and factor the common code out. |
| 32 |
|
| 33 |
# |
| 34 |
# unclaimed-category-1 test |
| 35 |
# |
| 36 |
# This test is special because we must compile two different modules, |
| 37 |
# unclaimed-category-1a.m and unclaimed-category-1.m, then link |
| 38 |
# together, then run the resulting executable. |
| 39 |
# for all systems we point to the libobjc includes and use the -fgnu-runtime |
| 40 |
set add_flags "additional_flags=-I${srcdir}/../../libobjc" |
| 41 |
lappend add_flags "additional_flags=-fgnu-runtime" |
| 42 |
lappend add_flags "additional_flags=-Wno-objc-root-class" |
| 43 |
set lines [objc_target_compile "$srcdir/$subdir/unclaimed-category-1a.m" "unclaimed-category-1a.o" object $add_flags ] |
| 44 |
if ![string match "" $lines] then { |
| 45 |
fail "unclaimed-category-1a.o" |
| 46 |
} else { |
| 47 |
dg-runtest "$srcdir/$subdir/unclaimed-category-1.m" "unclaimed-category-1a.o" "-I${srcdir}/../../libobjc -fgnu-runtime" |
| 48 |
file delete unclaimed-category-1a.o |
| 49 |
} |
| 50 |
|
| 51 |
if [istarget "*-*-darwin*" ] { |
| 52 |
set add_flags "" |
| 53 |
lappend add_flags "additional_flags=-fnext-runtime" |
| 54 |
lappend add_flags "additional_flags=-Wno-objc-root-class" |
| 55 |
set lines [objc_target_compile "$srcdir/$subdir/unclaimed-category-1a.m" "unclaimed-category-1a.o" object $add_flags ] |
| 56 |
if ![string match "" $lines] then { |
| 57 |
fail "unclaimed-category-1a.o" |
| 58 |
} else { |
| 59 |
dg-runtest "$srcdir/$subdir/unclaimed-category-1.m" "unclaimed-category-1a.o" "-fnext-runtime" |
| 60 |
file delete unclaimed-category-1a.o |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
# |
| 65 |
# load-category-1 test |
| 66 |
# |
| 67 |
# This test is similar to the one above. We compile load-category-1.m |
| 68 |
# and load-category-1a.m, link them together, and execute the result. |
| 69 |
set add_flags "additional_flags=-I${srcdir}/../../libobjc" |
| 70 |
lappend add_flags "additional_flags=-fgnu-runtime" |
| 71 |
lappend add_flags "additional_flags=-Wno-objc-root-class" |
| 72 |
set lines [objc_target_compile "$srcdir/$subdir/load-category-1a.m" "load-category-1a.o" object $add_flags ] |
| 73 |
if ![string match "" $lines] then { |
| 74 |
fail "load-category-1a.o" |
| 75 |
} else { |
| 76 |
dg-runtest "$srcdir/$subdir/load-category-1.m" "load-category-1a.o" "-I${srcdir}/../../libobjc -fgnu-runtime" |
| 77 |
file delete load-category-1a.o |
| 78 |
} |
| 79 |
|
| 80 |
if [istarget "*-*-darwin*" ] { |
| 81 |
set add_flags "" |
| 82 |
lappend add_flags "additional_flags=-fnext-runtime" |
| 83 |
lappend add_flags "additional_flags=-Wno-objc-root-class" |
| 84 |
set lines [objc_target_compile "$srcdir/$subdir/load-category-1a.m" "load-category-1a.o" object $add_flags ] |
| 85 |
if ![string match "" $lines] then { |
| 86 |
fail "load-category-1a.o" |
| 87 |
} else { |
| 88 |
dg-runtest "$srcdir/$subdir/load-category-1.m" "load-category-1a.o" "-fnext-runtime" |
| 89 |
file delete load-category-1a.o |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
# |
| 94 |
# load-category-2 test |
| 95 |
# |
| 96 |
# This test is similar to the one above. We compile load-category-2.m |
| 97 |
# and load-category-2a.m, link them together, and execute the result. |
| 98 |
set add_flags "additional_flags=-I${srcdir}/../../libobjc" |
| 99 |
lappend add_flags "additional_flags=-fgnu-runtime" |
| 100 |
lappend add_flags "additional_flags=-Wno-objc-root-class" |
| 101 |
set lines [objc_target_compile "$srcdir/$subdir/load-category-2a.m" "load-category-2a.o" object $add_flags ] |
| 102 |
if ![string match "" $lines] then { |
| 103 |
fail "load-category-2a.o" |
| 104 |
} else { |
| 105 |
dg-runtest "$srcdir/$subdir/load-category-2.m" "load-category-2a.o" "-I${srcdir}/../../libobjc -fgnu-runtime" |
| 106 |
file delete load-category-2a.o |
| 107 |
} |
| 108 |
|
| 109 |
if [istarget "*-*-darwin*" ] { |
| 110 |
set add_flags "" |
| 111 |
lappend add_flags "additional_flags=-fnext-runtime" |
| 112 |
lappend add_flags "additional_flags=-Wno-objc-root-class" |
| 113 |
set lines [objc_target_compile "$srcdir/$subdir/load-category-2a.m" "load-category-2a.o" object $add_flags ] |
| 114 |
if ![string match "" $lines] then { |
| 115 |
fail "load-category-2a.o" |
| 116 |
} else { |
| 117 |
dg-runtest "$srcdir/$subdir/load-category-2.m" "load-category-2a.o" "-fnext-runtime" |
| 118 |
file delete load-category-2a.o |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
# |
| 123 |
# load-category-3 test |
| 124 |
# |
| 125 |
# This test is similar to the one above. We compile load-category-3.m |
| 126 |
# and load-category-3a.m, link them together, and execute the result. |
| 127 |
set add_flags "additional_flags=-I${srcdir}/../../libobjc" |
| 128 |
lappend add_flags "additional_flags=-fgnu-runtime" |
| 129 |
lappend add_flags "additional_flags=-Wno-objc-root-class" |
| 130 |
set lines [objc_target_compile "$srcdir/$subdir/load-category-3a.m" "load-category-3a.o" object $add_flags ] |
| 131 |
if ![string match "" $lines] then { |
| 132 |
fail "load-category-3a.o" |
| 133 |
} else { |
| 134 |
dg-runtest "$srcdir/$subdir/load-category-3.m" "load-category-3a.o" "-I${srcdir}/../../libobjc -fgnu-runtime" |
| 135 |
file delete load-category-3a.o |
| 136 |
} |
| 137 |
|
| 138 |
if [istarget "*-*-darwin*" ] { |
| 139 |
set add_flags "" |
| 140 |
lappend add_flags "additional_flags=-fnext-runtime" |
| 141 |
lappend add_flags "additional_flags=-Wno-objc-root-class" |
| 142 |
set lines [objc_target_compile "$srcdir/$subdir/load-category-3a.m" "load-category-3a.o" object $add_flags ] |
| 143 |
if ![string match "" $lines] then { |
| 144 |
fail "load-category-3a.o" |
| 145 |
} else { |
| 146 |
dg-runtest "$srcdir/$subdir/load-category-3.m" "load-category-3a.o" "-fnext-runtime" |
| 147 |
file delete load-category-3a.o |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
# All done. |
| 152 |
dg-finish |
| 153 |
|