bug-gnulib
[Top][All Lists]
Advanced

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

improve clang support (22)


From: Bruno Haible
Subject: improve clang support (22)
Date: Tue, 11 Aug 2020 18:38:46 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

clang supports expression statement syntax (a block inside parentheses) like
GCC. This patch makes use of it.


2020-08-11  Bruno Haible  <bruno@clisp.org>

        Use expression statements also on clang.
        * lib/cdefs.h (__extension__): Don't define to empty on clang.
        * lib/obstack.h (__extension__): Likewise.
        (obstack_object_size, obstack_room, obstack_make_room, obstack_empty_p,
        obstack_grow, obstack_grow0, obstack_1grow, obstack_ptr_grow,
        obstack_int_grow, obstack_ptr_grow_fast, obstack_int_grow_fast,
        obstack_blank, obstack_alloc, obstack_copy, obstack_copy0,
        obstack_finish, obstack_free): Enable as optimized macros also on clang.
        * lib/fpucw.h (fpucw_t etc.): Enable the definitions also on clang.

diff --git a/lib/cdefs.h b/lib/cdefs.h
index 170d9e6..0065254 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -395,7 +395,7 @@
    run in pedantic mode if the uses are carefully marked using the
    `__extension__' keyword.  But this is not generally available before
    version 2.8.  */
-#if !__GNUC_PREREQ (2,8)
+#if !(__GNUC_PREREQ (2,8) || defined __clang__)
 # define __extension__         /* Ignore */
 #endif
 
diff --git a/lib/fpucw.h b/lib/fpucw.h
index 1c6edf6..8ef5420 100644
--- a/lib/fpucw.h
+++ b/lib/fpucw.h
@@ -61,8 +61,8 @@
                                     'long double' safe operation precision
  */
 
-/* Inline assembler like this works only with GNU C.  */
-#if (defined __i386__ || defined __x86_64__) && defined __GNUC__
+/* Inline assembler like this works only with GNU C and clang.  */
+#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__ || defined 
__clang__)
 
 typedef unsigned short fpucw_t; /* glibc calls this fpu_control_t */
 
diff --git a/lib/obstack.h b/lib/obstack.h
index 987bd3b..9452408 100644
--- a/lib/obstack.h
+++ b/lib/obstack.h
@@ -283,8 +283,9 @@ extern int obstack_exit_failure;
 
 #define obstack_memory_used(h) _obstack_memory_used (h)
 
-#if defined __GNUC__
-# if !defined __GNUC_MINOR__ || __GNUC__ * 1000 + __GNUC_MINOR__ < 2008
+#if defined __GNUC__ || defined __clang__
+# if !(defined __GNUC_MINOR__ && __GNUC__ * 1000 + __GNUC_MINOR__ >= 2008 \
+       || defined __clang__)
 #  define __extension__
 # endif
 




reply via email to

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