diff mbox

fix some -Werror fallout in the absence of FP round/exception support

Message ID 549DF5F0.8080904@ezchip.com
State New
Headers show

Commit Message

Chris Metcalf Dec. 26, 2014, 11:57 p.m. UTC
Due to tile missing a bunch of FP exception and rounding
support, the tests generate warnings.  These changes fix the
warnings by just not compiling some unused functions, and
adding some attribute((unused)) tags.

This seems pretty straightforward but I wanted to get some
signoff before committing.

2014-12-26  Chris Metcalf  <cmetcalf@ezchip.com>

         * math/test-fenv.c (test_single_exception, set_single_exc,
         feenv_nomask_test, feenv_mask_test, feexcp_nomask_test,
         feexcp_mask_test, feenable_test, fe_single_test): Add
         [!FE_ALL_EXCEPT] test so these routines are not compiled in the
         case where they are not used.
         * setjmp/test-setjmp-fp.c: Mark attribute((unused)) on variable
         unused in the absence of FP rounding/exception support.
         * stdio-common/tst-printf-round.c: Likewise.
         * stdlib/tst-strtod-round.c: Likewise.
         * stdlib/tst-strtod-underflow.c: Likewise.

Comments

Joseph Myers Dec. 30, 2014, 4:59 p.m. UTC | #1
On Fri, 26 Dec 2014, Chris Metcalf wrote:

> Due to tile missing a bunch of FP exception and rounding
> support, the tests generate warnings.  These changes fix the
> warnings by just not compiling some unused functions, and
> adding some attribute((unused)) tags.
> 
> This seems pretty straightforward but I wanted to get some
> signoff before committing.

OK with the missing space added between "__attribute__" and "((unused))" 
(throughout the patch).
Chris Metcalf Dec. 30, 2014, 7:12 p.m. UTC | #2
On 12/30/2014 11:59 AM, Joseph Myers wrote:
> On Fri, 26 Dec 2014, Chris Metcalf wrote:
>
>> Due to tile missing a bunch of FP exception and rounding
>> support, the tests generate warnings.  These changes fix the
>> warnings by just not compiling some unused functions, and
>> adding some attribute((unused)) tags.
>>
>> This seems pretty straightforward but I wanted to get some
>> signoff before committing.
> OK with the missing space added between "__attribute__" and "((unused))"
> (throughout the patch).

Thanks, pushed.
diff mbox

Patch

diff --git a/math/test-fenv.c b/math/test-fenv.c
index 23e47d4f3634..0783fb1c5ca3 100644
--- a/math/test-fenv.c
+++ b/math/test-fenv.c
@@ -54,6 +54,7 @@ 

  static int count_errors;

+#if FE_ALL_EXCEPT
  /* Test whether a given exception was raised.  */
  static void
  test_single_exception (short int exception,
@@ -84,6 +85,7 @@  test_single_exception (short int exception,
          }
      }
  }
+#endif

  static void
  test_exceptions (const char *test_name, short int exception,
@@ -164,6 +166,7 @@  test_rounding (const char *test_name, int rounding_mode)
  }


+#if FE_ALL_EXCEPT
  static void
  set_single_exc (const char *test_name, int fe_exc, fexcept_t exception)
  {
@@ -195,6 +198,7 @@  set_single_exc (const char *test_name, int fe_exc, fexcept_t exception)
    feclearexcept (exception);
    test_exceptions (str, ALL_EXC ^ fe_exc, 0);
  }
+#endif

  static void
  fe_tests (void)
@@ -227,11 +231,12 @@  fe_tests (void)
  #endif
  }

+#if FE_ALL_EXCEPT
  /* Test that program aborts with no masked interrupts */
  static void
  feenv_nomask_test (const char *flag_name, int fe_exc)
  {
-#if defined FE_NOMASK_ENV
+# if defined FE_NOMASK_ENV
    int status;
    pid_t pid;

@@ -247,13 +252,13 @@  feenv_nomask_test (const char *flag_name, int fe_exc)
    pid = fork ();
    if (pid == 0)
      {
-#ifdef RLIMIT_CORE
+#  ifdef RLIMIT_CORE
        /* Try to avoid dumping core.  */
        struct rlimit core_limit;
        core_limit.rlim_cur = 0;
        core_limit.rlim_max = 0;
        setrlimit (RLIMIT_CORE, &core_limit);
-#endif
+#  endif

        fesetenv (FE_NOMASK_ENV);
        feraiseexcept (fe_exc);
@@ -284,7 +289,7 @@  feenv_nomask_test (const char *flag_name, int fe_exc)
         ++count_errors;
        }
    }
-#endif
+# endif
  }

  /* Test that program doesn't abort with default environment */
@@ -613,6 +618,7 @@  fe_single_test (const char *flag_name, int fe_exc)
    feenv_mask_test (flag_name, fe_exc);
    feenable_test (flag_name, fe_exc);
  }
+#endif


  static void
diff --git a/setjmp/tst-setjmp-fp.c b/setjmp/tst-setjmp-fp.c
index d84c47ed5c4a..46e1573d25f2 100644
--- a/setjmp/tst-setjmp-fp.c
+++ b/setjmp/tst-setjmp-fp.c
@@ -22,7 +22,7 @@ 
  #include <stdio.h>
  #include <stdlib.h>

-static jmp_buf env;
+static jmp_buf __attribute__((unused)) env;
  static int result = 0;

  #if defined FE_TONEAREST && defined FE_TOWARDZERO
diff --git a/stdio-common/tst-printf-round.c b/stdio-common/tst-printf-round.c
index 5035ddae4ce4..462424e53c68 100644
--- a/stdio-common/tst-printf-round.c
+++ b/stdio-common/tst-printf-round.c
@@ -164,7 +164,7 @@  test_hex_in_one_mode (double d, const char *fmt, const char *const expected[4],
  static int
  do_test (void)
  {
-  int save_round_mode = fegetround ();
+  int save_round_mode __attribute__((unused)) = fegetround ();
    int result = 0;

    for (size_t i = 0; i < sizeof (dec_tests) / sizeof (dec_tests[0]); i++)
diff --git a/stdlib/tst-strtod-round.c b/stdlib/tst-strtod-round.c
index cbde45745158..ec13d720aa2f 100644
--- a/stdlib/tst-strtod-round.c
+++ b/stdlib/tst-strtod-round.c
@@ -7874,7 +7874,7 @@  test_in_one_mode (const char *s, const struct test_results *expected,
  static int
  do_test (void)
  {
-  int save_round_mode = fegetround ();
+  int save_round_mode __attribute__((unused)) = fegetround ();
    int result = 0;
    for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
      {
diff --git a/stdlib/tst-strtod-underflow.c b/stdlib/tst-strtod-underflow.c
index bc2374188bdf..eebc9f9d857e 100644
--- a/stdlib/tst-strtod-underflow.c
+++ b/stdlib/tst-strtod-underflow.c
@@ -171,7 +171,7 @@  test_in_one_mode (const char *s, enum underflow_case c, int rm,
  static int
  do_test (void)
  {
-  int save_round_mode = fegetround ();
+  int save_round_mode __attribute__((unused)) = fegetround ();
    int result = 0;
  #ifdef FE_TONEAREST
    const int fe_tonearest = FE_TONEAREST;