[m-rev.] for review: avoid test failures in hlc grades with GCC 12

Julien Fischer jfischer at opturion.com
Fri Jul 1 23:04:04 AEST 2022


For review by anyone.

Five of the six tests mentioned below trigger the Mercury compiler's own
infinite recursion warning. The one test that does not do that but does
get a warning from GCC is tests/valid/higher_order5.m.  In that case GCC,
has the advantage of seeing the code after the call to the function id/1
has been inlined into the body of definite_vars/3.

-----------------------------

Avoid test failures in hlc grades with GCC 12.

GCC 12 has a new warning, -Winfinite-recursion, which is triggered by six of
the tests in tests/valid.  Because we also use -Werror, those tests now fail.

configure.ac:
scripts/mgnuc.in:
      When using GCC 12 or higher, compile with -Wno-infinite-recursion
      in order to avoid the above failures.

Julien.

diff --git a/configure.ac b/configure.ac
index 871cbe5..33d4377 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4395,6 +4395,14 @@ case "$mercury_cv_cc_type" in
              ;;
          esac

+        # See scripts/mgnuc.in for an explanation of why we set
+        # -Wno-infinite-recursion here.
+        case "$C_COMPILER_TYPE" in
+            gcc_1[[2-9]]_*)
+                CFLAGS_FOR_WARNINGS="$CFLAGS_FOR_WARNINGS -Wno-infinite-recursion"
+            ;;
+        esac
+
          # Enabling -fomit-frame-pointer causes setjmp/longjmp to misbehave
          # with MinGW on Windows XP.
          case "$host" in
diff --git a/scripts/mgnuc.in b/scripts/mgnuc.in
index 649539e..9e007bd 100755
--- a/scripts/mgnuc.in
+++ b/scripts/mgnuc.in
@@ -583,6 +583,15 @@ case "${C_COMPILER_TYPE}" in
      ;;
  esac

+# Disable the warnings about infinite recursion generated by GCC 12
+# onwards. These cause several of the tests in tests/valid to fail
+# in hlc grades due to -Werror also being enabled.
+case "${C_COMPILER_TYPE}" in
+    gcc_1[2-9]_*)
+        CHECK_OPTS="${CHECK_OPTS} -Wno-infinite-recursion"
+    ;;
+esac
+
  case ${COMPILER} in gcc)
      case "${FULLARCH}" in
          i*86*)



More information about the reviews mailing list