c-compat.exp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # Copyright (C) 2002-2015 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with GCC; see the file COPYING3. If not see
  14. # <http://www.gnu.org/licenses/>.
  15. # Please email any bugs, comments, and/or additions to this file to:
  16. # gcc-patches@gcc.gnu.org
  17. # Globals.
  18. global compat_use_alt
  19. global compat_same_alt
  20. global compat_have_dfp
  21. global compat_skip_list
  22. # This file defines procs for determining features supported by both C
  23. # compilers for compatibility tests.
  24. load_lib target-supports.exp
  25. load_lib target-libpath.exp
  26. #
  27. # compat-use-alt-compiler -- make the alternate compiler the default
  28. #
  29. proc compat-use-alt-compiler { } {
  30. global GCC_UNDER_TEST ALT_CC_UNDER_TEST
  31. global compat_same_alt compat_alt_caret compat_alt_color
  32. global TEST_ALWAYS_FLAGS
  33. # We don't need to do this if the alternate compiler is actually
  34. # the same as the compiler under test.
  35. if { $compat_same_alt == 0 } then {
  36. set GCC_UNDER_TEST $ALT_CC_UNDER_TEST
  37. if { $compat_alt_caret == 0 } then {
  38. regsub -- "-fno-diagnostics-show-caret" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
  39. }
  40. if { $compat_alt_color == 0 } then {
  41. regsub -- "-fdiagnostics-color=never" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
  42. }
  43. restore_gcc_exec_prefix_env_var
  44. }
  45. }
  46. #
  47. # compat-use-tst-compiler -- make compiler under test the default
  48. #
  49. proc compat-use-tst-compiler { } {
  50. global GCC_UNDER_TEST compat_save_gcc_under_test
  51. global compat_same_alt
  52. global TEST_ALWAYS_FLAGS compat_save_TEST_ALWAYS_FLAGS
  53. # We don't need to do this if the alternate compiler is actually
  54. # the same as the compiler under test.
  55. if { $compat_same_alt == 0 } then {
  56. set GCC_UNDER_TEST $compat_save_gcc_under_test
  57. set TEST_ALWAYS_FLAGS $compat_save_TEST_ALWAYS_FLAGS
  58. set_gcc_exec_prefix_env_var
  59. }
  60. }
  61. # Find out whether both compilers support decimal float types.
  62. proc compat_setup_dfp { } {
  63. global compat_use_alt
  64. global compat_same_alt
  65. global compat_have_dfp
  66. global compat_alt_caret
  67. global compat_alt_color
  68. global TEST_ALWAYS_FLAGS compat_save_TEST_ALWAYS_FLAGS
  69. set compat_alt_caret 0
  70. set compat_alt_color 0
  71. set compat_save_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
  72. verbose "compat_setup_dfp: $compat_use_alt $compat_same_alt" 2
  73. # Does the compiler under test support decimal float types?
  74. compat-use-tst-compiler
  75. set compat_have_dfp [check_effective_target_dfprt_nocache]
  76. verbose "compat_have_dfp for tst compiler: $compat_have_dfp" 2
  77. if { $compat_use_alt == 1 && $compat_same_alt == 0 } {
  78. compat-use-alt-compiler
  79. if { [check_no_compiler_messages_nocache compat_alt_has_caret object {
  80. int dummy; } "-fno-diagnostics-show-caret"] != 0 } {
  81. set compat_alt_caret 1
  82. }
  83. if { [check_no_compiler_messages_nocache compat_alt_has_color object {
  84. int dummy; } "-fdiagnostics-color=never"] != 0 } {
  85. set compat_alt_color 1
  86. }
  87. compat-use-tst-compiler
  88. }
  89. # If there is an alternate compiler, does it support decimal float types?
  90. if { $compat_have_dfp == 1 && $compat_use_alt == 1 && $compat_same_alt == 0 } {
  91. compat-use-alt-compiler
  92. set compat_have_dfp [check_effective_target_dfprt_nocache]
  93. compat-use-tst-compiler
  94. verbose "compat_have_dfp for alt compiler: $compat_have_dfp" 2
  95. }
  96. # If decimal float is not supported, add it to the skip list, which
  97. # affects code in the header files.
  98. if { $compat_have_dfp == 0 } {
  99. global compat_skip_list
  100. lappend compat_skip_list "DECIMAL_FLOAT"
  101. }
  102. }
  103. # If either compiler does not support decimal float types, skip this test.
  104. proc dg-require-compat-dfp { args } {
  105. global compat_have_dfp
  106. if { $compat_have_dfp == 0 } {
  107. upvar dg-do-what dg-do-what
  108. set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
  109. }
  110. }