Rebase.
[official-gcc.git] / gcc / testsuite / lib / c-compat.exp
blobf5b461e473dd06256978996e504fb69fa4f2a001
1 # Copyright (C) 2002-2014 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.
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 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
20 # Globals.
22 global compat_use_alt
23 global compat_same_alt
24 global compat_have_dfp
25 global compat_skip_list
27 # This file defines procs for determining features supported by both C
28 # compilers for compatibility tests.
30 load_lib target-supports.exp
31 load_lib target-libpath.exp
34 # compat-use-alt-compiler -- make the alternate compiler the default
36 proc compat-use-alt-compiler { } {
37 global GCC_UNDER_TEST ALT_CC_UNDER_TEST
38 global compat_same_alt compat_alt_caret compat_alt_color
39 global TEST_ALWAYS_FLAGS
41 # We don't need to do this if the alternate compiler is actually
42 # the same as the compiler under test.
43 if { $compat_same_alt == 0 } then {
44 set GCC_UNDER_TEST $ALT_CC_UNDER_TEST
45 if { $compat_alt_caret == 0 } then {
46 regsub -- "-fno-diagnostics-show-caret" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
48 if { $compat_alt_color == 0 } then {
49 regsub -- "-fdiagnostics-color=never" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
51 restore_gcc_exec_prefix_env_var
56 # compat-use-tst-compiler -- make compiler under test the default
58 proc compat-use-tst-compiler { } {
59 global GCC_UNDER_TEST compat_save_gcc_under_test
60 global compat_same_alt
61 global TEST_ALWAYS_FLAGS compat_save_TEST_ALWAYS_FLAGS
63 # We don't need to do this if the alternate compiler is actually
64 # the same as the compiler under test.
66 if { $compat_same_alt == 0 } then {
67 set GCC_UNDER_TEST $compat_save_gcc_under_test
68 set TEST_ALWAYS_FLAGS $compat_save_TEST_ALWAYS_FLAGS
69 set_gcc_exec_prefix_env_var
73 # Find out whether both compilers support decimal float types.
74 proc compat_setup_dfp { } {
75 global compat_use_alt
76 global compat_same_alt
77 global compat_have_dfp
78 global compat_alt_caret
79 global compat_alt_color
80 global TEST_ALWAYS_FLAGS compat_save_TEST_ALWAYS_FLAGS
82 set compat_alt_caret 0
83 set compat_alt_color 0
84 set compat_save_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
86 verbose "compat_setup_dfp: $compat_use_alt $compat_same_alt" 2
88 # Does the compiler under test support decimal float types?
89 compat-use-tst-compiler
90 set compat_have_dfp [check_effective_target_dfprt_nocache]
91 verbose "compat_have_dfp for tst compiler: $compat_have_dfp" 2
93 if { $compat_use_alt == 1 && $compat_same_alt == 0 } {
94 compat-use-alt-compiler
95 if { [check_no_compiler_messages_nocache compat_alt_has_caret object {
96 int dummy; } "-fno-diagnostics-show-caret"] != 0 } {
97 set compat_alt_caret 1
99 if { [check_no_compiler_messages_nocache compat_alt_has_color object {
100 int dummy; } "-fdiagnostics-color=never"] != 0 } {
101 set compat_alt_color 1
103 compat-use-tst-compiler
106 # If there is an alternate compiler, does it support decimal float types?
107 if { $compat_have_dfp == 1 && $compat_use_alt == 1 && $compat_same_alt == 0 } {
108 compat-use-alt-compiler
109 set compat_have_dfp [check_effective_target_dfprt_nocache]
110 compat-use-tst-compiler
111 verbose "compat_have_dfp for alt compiler: $compat_have_dfp" 2
114 # If decimal float is not supported, add it to the skip list, which
115 # affects code in the header files.
116 if { $compat_have_dfp == 0 } {
117 global compat_skip_list
118 lappend compat_skip_list "DECIMAL_FLOAT"
122 # If either compiler does not support decimal float types, skip this test.
124 proc dg-require-compat-dfp { args } {
125 global compat_have_dfp
126 if { $compat_have_dfp == 0 } {
127 upvar dg-do-what dg-do-what
128 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]