]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/lib/c-compat.exp
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / lib / c-compat.exp
CommitLineData
99dee823 1# Copyright (C) 2002-2021 Free Software Foundation, Inc.
27a2694f
JJ
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
cd976c16 5# the Free Software Foundation; either version 3 of the License, or
27a2694f
JJ
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
cd976c16
NC
14# along with GCC; see the file COPYING3. If not see
15# <http://www.gnu.org/licenses/>.
27a2694f
JJ
16
17# Please email any bugs, comments, and/or additions to this file to:
18# gcc-patches@gcc.gnu.org
19
20# Globals.
21
22global compat_use_alt
23global compat_same_alt
24global compat_have_dfp
25global compat_skip_list
26
27# This file defines procs for determining features supported by both C
28# compilers for compatibility tests.
29
30load_lib target-supports.exp
51db86a8 31load_lib target-libpath.exp
27a2694f
JJ
32
33#
34# compat-use-alt-compiler -- make the alternate compiler the default
35#
36proc compat-use-alt-compiler { } {
37 global GCC_UNDER_TEST ALT_CC_UNDER_TEST
bd38d0da 38 global compat_same_alt compat_alt_caret compat_alt_color compat_no_line_no
129a1319 39 global compat_alt_urls compat_alt_plain_output
868f97d5 40 global TEST_ALWAYS_FLAGS
27a2694f
JJ
41
42 # We don't need to do this if the alternate compiler is actually
43 # the same as the compiler under test.
44 if { $compat_same_alt == 0 } then {
45 set GCC_UNDER_TEST $ALT_CC_UNDER_TEST
129a1319
LH
46
47 # These flags are no longer added to TEST_ALWAYS_FLAGS by prune.exp
48 # because they are subsumed by -fdiagnostics-plain-output. Add them back
49 # for compatibility testing with older compilers that do not understand
50 # -fdiagnostics-plain-output.
51 set TEST_ALWAYS_FLAGS "-fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers -fdiagnostics-color=never -fdiagnostics-urls=never $TEST_ALWAYS_FLAGS"
52
868f97d5 53 if { $compat_alt_caret == 0 } then {
129a1319 54 regsub -all -- "-fno-diagnostics-show-caret" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
868f97d5 55 }
a2e836b2 56 if { $compat_alt_color == 0 } then {
129a1319 57 regsub -all -- "-fdiagnostics-color=never" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
a2e836b2 58 }
40111910 59 if { $compat_alt_urls == 0 } then {
129a1319 60 regsub -all -- "-fdiagnostics-urls=never" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
40111910 61 }
bd38d0da 62 if { $compat_no_line_no == 0 } then {
129a1319
LH
63 regsub -all -- "-fno-diagnostics-show-line-numbers" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
64 }
65 if { $compat_alt_plain_output == 0 } then {
66 regsub -all -- "-fdiagnostics-plain-output" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
bd38d0da 67 }
51db86a8 68 restore_gcc_exec_prefix_env_var
27a2694f
JJ
69 }
70}
71
72#
73# compat-use-tst-compiler -- make compiler under test the default
74#
75proc compat-use-tst-compiler { } {
76 global GCC_UNDER_TEST compat_save_gcc_under_test
77 global compat_same_alt
868f97d5 78 global TEST_ALWAYS_FLAGS compat_save_TEST_ALWAYS_FLAGS
27a2694f
JJ
79
80 # We don't need to do this if the alternate compiler is actually
81 # the same as the compiler under test.
82
83 if { $compat_same_alt == 0 } then {
84 set GCC_UNDER_TEST $compat_save_gcc_under_test
868f97d5 85 set TEST_ALWAYS_FLAGS $compat_save_TEST_ALWAYS_FLAGS
51db86a8 86 set_gcc_exec_prefix_env_var
27a2694f
JJ
87 }
88}
89
90# Find out whether both compilers support decimal float types.
91proc compat_setup_dfp { } {
92 global compat_use_alt
93 global compat_same_alt
94 global compat_have_dfp
868f97d5 95 global compat_alt_caret
a2e836b2 96 global compat_alt_color
40111910 97 global compat_alt_urls
129a1319 98 global compat_alt_plain_output
bd38d0da 99 global compat_no_line_no
868f97d5
JJ
100 global TEST_ALWAYS_FLAGS compat_save_TEST_ALWAYS_FLAGS
101
102 set compat_alt_caret 0
a2e836b2 103 set compat_alt_color 0
40111910 104 set compat_alt_urls 0
129a1319 105 set compat_alt_plain_output 0
bd38d0da 106 set compat_no_line_no 0
868f97d5 107 set compat_save_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
27a2694f
JJ
108
109 verbose "compat_setup_dfp: $compat_use_alt $compat_same_alt" 2
6efbd94a
DJ
110
111 # Does the compiler under test support decimal float types?
112 compat-use-tst-compiler
113 set compat_have_dfp [check_effective_target_dfprt_nocache]
114 verbose "compat_have_dfp for tst compiler: $compat_have_dfp" 2
115
868f97d5
JJ
116 if { $compat_use_alt == 1 && $compat_same_alt == 0 } {
117 compat-use-alt-compiler
118 if { [check_no_compiler_messages_nocache compat_alt_has_caret object {
119 int dummy; } "-fno-diagnostics-show-caret"] != 0 } {
120 set compat_alt_caret 1
121 }
a2e836b2
JJ
122 if { [check_no_compiler_messages_nocache compat_alt_has_color object {
123 int dummy; } "-fdiagnostics-color=never"] != 0 } {
124 set compat_alt_color 1
125 }
40111910
JJ
126 if { [check_no_compiler_messages_nocache compat_alt_has_urls object {
127 int dummy; } "-fdiagnostics-urls=never"] != 0 } {
128 set compat_alt_urls 1
129 }
bd38d0da
IS
130 if { [check_no_compiler_messages_nocache compat_alt_has_no_line_no object {
131 int dummy; } "-fno-diagnostics-show-line-numbers"] != 0 } {
132 set compat_no_line_no 1
133 }
129a1319
LH
134 if { [check_no_compiler_messages_nocache compat_alt_has_plain_output object {
135 int dummy; } "-fdiagnostics-plain-output"] != 0 } {
136 set compat_alt_plain_output 1
137 }
bd38d0da 138
868f97d5
JJ
139 compat-use-tst-compiler
140 }
141
27a2694f 142 # If there is an alternate compiler, does it support decimal float types?
6efbd94a 143 if { $compat_have_dfp == 1 && $compat_use_alt == 1 && $compat_same_alt == 0 } {
27a2694f 144 compat-use-alt-compiler
265e7d50 145 set compat_have_dfp [check_effective_target_dfprt_nocache]
27a2694f
JJ
146 compat-use-tst-compiler
147 verbose "compat_have_dfp for alt compiler: $compat_have_dfp" 2
148 }
27a2694f
JJ
149
150 # If decimal float is not supported, add it to the skip list, which
151 # affects code in the header files.
152 if { $compat_have_dfp == 0 } {
153 global compat_skip_list
154 lappend compat_skip_list "DECIMAL_FLOAT"
155 }
156}
157
27a2694f
JJ
158# If either compiler does not support decimal float types, skip this test.
159
160proc dg-require-compat-dfp { args } {
161 global compat_have_dfp
162 if { $compat_have_dfp == 0 } {
163 upvar dg-do-what dg-do-what
164 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
165 }
166}