bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fix compilation errors in C++ mode on FreeBSD


From: Bruno Haible
Subject: fix compilation errors in C++ mode on FreeBSD
Date: Sun, 08 Dec 2019 13:22:55 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

In a testdir created with --with-c++-tests, on FreeBSD 12, I see these errors:

depbase=`echo test-pthread-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
c++ -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I../../gltests -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. 
-I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/home/bruno/include 
-Wall -D_THREAD_SAFE   -MT test-pthread-c++.o -MD -MP -MF $depbase.Tpo -c -o 
test-pthread-c++.o ../../gltests/test-pthread-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from ../../gltests/test-pthread-c++.cc:22:
../gllib/pthread.h:1207:38: error: an attribute list cannot appear here
_GL_CXXALIAS_SYS_CAST (pthread_exit, _Noreturn void, (void *value));
                                     ^~~~~~~~~
/usr/include/sys/cdefs.h:280:20: note: expanded from macro '_Noreturn'
#define _Noreturn               [[noreturn]]
                                ^~~~~~~~~~~~
../gllib/time.h:267:17: note: expanded from macro '_GL_CXXALIAS_SYS_CAST'
        typedef rettype (*type) parameters;             \
                ^~~~~~~
../../gltests/test-pthread-c++.cc:71:50: error: an attribute list cannot appear 
here
SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_exit, _Noreturn void, (void *));
                                                 ^~~~~~~~~
/usr/include/sys/cdefs.h:280:20: note: expanded from macro '_Noreturn'
#define _Noreturn               [[noreturn]]
                                ^~~~~~~~~~~~
../../gltests/signature.h:39:25: note: expanded from macro 'SIGNATURE_CHECK'
  SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
                        ^~~
../../gltests/signature.h:44:25: note: expanded from macro 'SIGNATURE_CHECK1'
  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
                        ^~~
../../gltests/signature.h:46:10: note: expanded from macro 'SIGNATURE_CHECK2'
  static ret (* _GL_UNUSED signature_check ## id) args = fn
         ^~~
2 errors generated.
gmake[2]: *** [Makefile:9875: test-pthread-c++.o] Error 1

depbase=`echo test-threads-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
c++ -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I../../gltests -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. 
-I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/home/bruno/include 
-Wall -D_THREAD_SAFE   -MT test-threads-c++.o -MD -MP -MF $depbase.Tpo -c -o 
test-threads-c++.o ../../gltests/test-threads-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from ../../gltests/test-threads-c++.cc:22:
../gllib/threads.h:786:35: error: an attribute list cannot appear here
_GL_CXXALIAS_SYS_CAST (thrd_exit, _Noreturn void, (int));
                                  ^~~~~~~~~
/usr/include/sys/cdefs.h:280:20: note: expanded from macro '_Noreturn'
#define _Noreturn               [[noreturn]]
                                ^~~~~~~~~~~~
../gllib/time.h:267:17: note: expanded from macro '_GL_CXXALIAS_SYS_CAST'
        typedef rettype (*type) parameters;             \
                ^~~~~~~
../../gltests/test-threads-c++.cc:37:47: error: an attribute list cannot appear 
here
SIGNATURE_CHECK (GNULIB_NAMESPACE::thrd_exit, _Noreturn void, (int));
                                              ^~~~~~~~~
/usr/include/sys/cdefs.h:280:20: note: expanded from macro '_Noreturn'
#define _Noreturn               [[noreturn]]
                                ^~~~~~~~~~~~
../../gltests/signature.h:39:25: note: expanded from macro 'SIGNATURE_CHECK'
  SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
                        ^~~
../../gltests/signature.h:44:25: note: expanded from macro 'SIGNATURE_CHECK1'
  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
                        ^~~
../../gltests/signature.h:46:10: note: expanded from macro 'SIGNATURE_CHECK2'
  static ret (* _GL_UNUSED signature_check ## id) args = fn
         ^~~
2 errors generated.
gmake[2]: *** [Makefile:9875: test-threads-c++.o] Error 1

Although gnulib no longer maps '_Noreturn' to '[[noreturn]]', since
<https://lists.gnu.org/archive/html/bug-gnulib/2019-12/msg00013.html>, the
<sys/cdefs.h> file of FreeBSD still does the same thing. While not a universal
fix, the following fixes the issues shown above. It is still necessary to use
_GL_CXXALIAS_SYS_CAST on these two functions, because of AIX.


2019-12-08  Bruno Haible  <address@hidden>

        Fix compilation errors in C++ mode on FreeBSD.
        * lib/pthread.in.h (pthread_exit): Remove _Noreturn from prototype.
        * tests/test-pthread-c++.cc (GNULIB_NAMESPACE::pthread_exit): Likewise.
        * lib/threads.in.h (thrd_exit): Likewise.
        * tests/test-threads-c++.cc (GNULIB_NAMESPACE::thrd_exit): Likewise.

diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index 4ba7e7b..a70d023 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -689,9 +689,8 @@ _GL_CXXALIAS_RPL (pthread_exit, _Noreturn void, (void 
*value));
 #  if !@HAVE_PTHREAD_EXIT@
 _GL_FUNCDECL_SYS (pthread_exit, _Noreturn void, (void *value));
 #  endif
-/* Need to cast, because on AIX with xlclang++, the return type is
-                                     void.  */
-_GL_CXXALIAS_SYS_CAST (pthread_exit, _Noreturn void, (void *value));
+/* Need to cast because of AIX with xlclang++.  */
+_GL_CXXALIAS_SYS_CAST (pthread_exit, void, (void *value));
 # endif
 _GL_CXXALIASWARN (pthread_exit);
 #elif defined GNULIB_POSIXCHECK
diff --git a/lib/threads.in.h b/lib/threads.in.h
index 3136257..5fcbb09 100644
--- a/lib/threads.in.h
+++ b/lib/threads.in.h
@@ -268,9 +268,8 @@ _GL_WARN_ON_USE (thrd_join, "thrd_join is unportable - "
 # if !@HAVE_THREADS_H@
 _GL_FUNCDECL_SYS (thrd_exit, _Noreturn void, (int));
 # endif
-/* Need to cast, because on AIX with xlclang++, the return type is
-                                  void.  */
-_GL_CXXALIAS_SYS_CAST (thrd_exit, _Noreturn void, (int));
+/* Need to cast because of AIX with xlclang++.  */
+_GL_CXXALIAS_SYS_CAST (thrd_exit, void, (int));
 _GL_CXXALIASWARN (thrd_exit);
 #elif defined GNULIB_POSIXCHECK
 # undef thrd_exit
diff --git a/tests/test-pthread-c++.cc b/tests/test-pthread-c++.cc
index aa221bc..43f1b97 100644
--- a/tests/test-pthread-c++.cc
+++ b/tests/test-pthread-c++.cc
@@ -68,7 +68,7 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_join, int, 
(pthread_t, void **));
 #endif
 
 #if GNULIB_TEST_PTHREAD_THREAD
-SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_exit, _Noreturn void, (void *));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_exit, void, (void *));
 #endif
 
 /* =========== Once-only control (initialization) functions =========== */
diff --git a/tests/test-threads-c++.cc b/tests/test-threads-c++.cc
index ae0d865..07da403 100644
--- a/tests/test-threads-c++.cc
+++ b/tests/test-threads-c++.cc
@@ -34,7 +34,7 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::thrd_sleep, int,
 SIGNATURE_CHECK (GNULIB_NAMESPACE::thrd_yield, void, (void));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::thrd_detach, int, (thrd_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::thrd_join, int, (thrd_t, int *));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::thrd_exit, _Noreturn void, (int));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::thrd_exit, void, (int));
 #endif
 
 #if GNULIB_TEST_MTX




reply via email to

[Prev in Thread] Current Thread [Next in Thread]