changeset 30531:492a37a18b81 stable

Guard usage of non-standard pragmas. * configure.ac (HAVE_PRAGMA_GCC_VISIBILITY): Add new test for "#pragma GCC visibility". (HAVE_PRAGMA_GCC_DIAGNOSTIC): Fix typo in test. * libinterp/template-inst/Array-tc.cc: Use HAVE_PRAGMA_GCC_VISIBILITY. * liboctave/util/blaswrap.c: Use HAVE_PRAGMA_GCC_DIAGNOSTIC. * liboctave/wrappers/stat-wrappers.c, liboctave/wrappers/wait-wrappers.c: Fix indentation.
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 23 Dec 2021 11:55:09 +0100
parents 332e5cbe3fa6
children 5ff87e646505 022747aca7fe
files configure.ac libinterp/template-inst/Array-tc.cc liboctave/util/blaswrap.c liboctave/wrappers/stat-wrappers.c liboctave/wrappers/wait-wrappers.c
diffstat 5 files changed, 38 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Thu Dec 23 15:24:55 2021 +0100
+++ b/configure.ac	Thu Dec 23 11:55:09 2021 +0100
@@ -2842,11 +2842,11 @@
 ### Check for GCC-specific pragmas to control warnings.
 
 AC_LANG_PUSH(C++)
-AC_CACHE_CHECK([for @%:@pragma GCC diagnostic push/pop/ignore],
+AC_CACHE_CHECK([for @%:@pragma GCC diagnostic push/pop/ignored],
   [octave_cv_gcc_has_pragma_GCC_diagnostic],
   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
 #pragma GCC diagnostic push
-#pragma GCC diagnostic ignore "-Wold-style-cast"
+#pragma GCC diagnostic ignored "-Wold-style-cast"
   int three = (int) 3.1415926;
 #pragma GCC diagnostic pop
     ]])],
@@ -2857,14 +2857,30 @@
 
 if test $octave_cv_gcc_has_pragma_GCC_diagnostic = yes; then
   AC_DEFINE(HAVE_PRAGMA_GCC_DIAGNOSTIC, 1,
-    [Define to 1 if GCC supports @%:@pragma GCC diagnostic ...])
+    [Define to 1 if compiler supports @%:@pragma GCC diagnostic ...])
+fi
+
+AC_CACHE_CHECK([for @%:@pragma GCC visibility push/pop],
+  [octave_cv_gcc_has_pragma_GCC_visiblity],
+  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+#pragma GCC visibility push(default)
+  int three = 3;
+#pragma GCC visiblity pop(default)
+    ]])],
+    [octave_cv_gcc_has_pragma_GCC_visiblity=yes],
+    [octave_cv_gcc_has_pragma_GCC_visiblity=no])],
+  ])
+
+if test $octave_cv_gcc_has_pragma_GCC_visiblity = yes; then
+  AC_DEFINE(HAVE_PRAGMA_GCC_VISIBILITY, 1,
+    [Define to 1 if compiler supports @%:@pragma GCC visiblity ...])
 fi
 
 ## Check for one unusual warning used in pragmas that is not always available
 if test $octave_cv_gcc_has_pragma_GCC_diagnostic = yes; then
   OCTAVE_CC_FLAG([-Wimplicit-fallthrough],
     [AC_DEFINE(HAVE_WARN_IMPLICIT_FALLTHROUGH, 1,
-      [Define to 1 if GCC supports -Wimplicit-fallthrough warning])])
+      [Define to 1 if compiler supports -Wimplicit-fallthrough warning])])
 fi
 
 ### These are recommended by the gnulib bootstrap script:
--- a/libinterp/template-inst/Array-tc.cc	Thu Dec 23 15:24:55 2021 +0100
+++ b/libinterp/template-inst/Array-tc.cc	Thu Dec 23 11:55:09 2021 +0100
@@ -51,9 +51,12 @@
 extern template class Array<octave_idx_type>;
 extern template class Array<std::string>;
 
+#if defined (HAVE_PRAGMA_GCC_VISIBILITY)
 // Visibility attributes are ignored on template instantiation.
 // As a work-around, set visibility to default overriding compiler options.
-#pragma GCC visibility push(default)
+#  pragma GCC visibility push(default)
+#endif
+
 NO_INSTANTIATE_ARRAY_SORT_API (octave_value, OCTINTERP_API);
 INSTANTIATE_ARRAY (octave_value, OCTINTERP_API);
 
@@ -62,5 +65,8 @@
 
 NO_INSTANTIATE_ARRAY_SORT_API (octave::cdef_object, OCTINTERP_API);
 INSTANTIATE_ARRAY (octave::cdef_object, OCTINTERP_API);
-#pragma GCC visibility pop
 
+#if defined (HAVE_PRAGMA_GCC_VISIBILITY)
+#  pragma GCC visibility pop
+#endif
+
--- a/liboctave/util/blaswrap.c	Thu Dec 23 15:24:55 2021 +0100
+++ b/liboctave/util/blaswrap.c	Thu Dec 23 11:55:09 2021 +0100
@@ -33,7 +33,7 @@
 they should.  This breaks them in 64-bit builds on the x86_64
 architecture.
 
-Newer gfortran compoilers no longer default to the F2C calling
+Newer gfortran compilers no longer default to the F2C calling
 convention.  These wrappers map the F2C conformant functions in
 libBLAS and libLAPACK to the native gfortran calling convention, so
 that the libraries can be used with software built for x86_64
@@ -59,11 +59,13 @@
 #  define VECLIB_FILE "/System/Library/Frameworks/vecLib.framework/Versions/A/vecLib"
 #endif
 
+#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
 /*
  * Since this is a wrapper for fortran functions,
  * we do not have prototypes for them.
  */
-#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#  pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#endif
 
 #include <dlfcn.h>
 #include <stdlib.h>
--- a/liboctave/wrappers/stat-wrappers.c	Thu Dec 23 15:24:55 2021 +0100
+++ b/liboctave/wrappers/stat-wrappers.c	Thu Dec 23 11:55:09 2021 +0100
@@ -176,8 +176,8 @@
 // Disable the unused parameter warning for the following wrapper functions.
 // The <sys/stat.h> header provided by gnulib may define some of the S_IS*
 // macros to expand to a constant and ignore the parameter.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wunused-parameter"
 #endif
 
 bool
@@ -252,7 +252,7 @@
 
 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
 // Restore prevailing warning state for remainder of the file.
-#pragma GCC diagnostic pop
+#  pragma GCC diagnostic pop
 #endif
 
 bool
--- a/liboctave/wrappers/wait-wrappers.c	Thu Dec 23 15:24:55 2021 +0100
+++ b/liboctave/wrappers/wait-wrappers.c	Thu Dec 23 11:55:09 2021 +0100
@@ -124,8 +124,8 @@
 // Disable the unused parameter warning for the following wrapper functions.
 // The <sys/wait.h> header provided by gnulib may define some of the W*
 // macros to expand to a constant and ignore the parameter.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wunused-parameter"
 #endif
 
 int
@@ -178,5 +178,5 @@
 
 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
 // Restore prevailing warning state for remainder of the file.
-#pragma GCC diagnostic pop
+#  pragma GCC diagnostic pop
 #endif