[cfe-commits] r89459 - in /cfe/trunk: lib/Headers/stdint.h test/Preprocessor/stdint.c

Ken Dyck ken.dyck at onsemi.com
Fri Nov 20 08:37:35 PST 2009


Author: kjdyck
Date: Fri Nov 20 10:37:35 2009
New Revision: 89459

URL: http://llvm.org/viewvc/llvm-project?rev=89459&view=rev
Log:
Avoid unwanted macro expansion in macros that paste together int<n>_t and
uint<n>_t definitions.


Modified:
    cfe/trunk/lib/Headers/stdint.h
    cfe/trunk/test/Preprocessor/stdint.c

Modified: cfe/trunk/lib/Headers/stdint.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/stdint.h?rev=89459&r1=89458&r2=89459&view=diff

==============================================================================
--- cfe/trunk/lib/Headers/stdint.h (original)
+++ cfe/trunk/lib/Headers/stdint.h Fri Nov 20 10:37:35 2009
@@ -216,16 +216,19 @@
 #define __stdint_join3(a,b,c) a ## b ## c
 #define __stdint_exjoin3(a,b,c) __stdint_join3(a,b,c)
 
+#define  __intn_t(n) __stdint_join3( int, n, _t)
+#define __uintn_t(n) __stdint_join3(uint, n, _t)
+
 #ifndef __intptr_t_defined
-typedef __stdint_exjoin3( int, __INTPTR_WIDTH__, _t) intptr_t;
+typedef  __intn_t(__INTPTR_WIDTH__)  intptr_t;
 #define __intptr_t_defined
 #endif
-typedef __stdint_exjoin3(uint, __INTPTR_WIDTH__, _t) uintptr_t;
+typedef __uintn_t(__INTPTR_WIDTH__) uintptr_t;
 
 /* C99 7.18.1.5 Greatest-width integer types.
  */
-typedef __stdint_exjoin3( int, __INTMAX_WIDTH__, _t) intmax_t;
-typedef __stdint_exjoin3(uint, __INTMAX_WIDTH__, _t) uintmax_t;
+typedef  __intn_t(__INTMAX_WIDTH__)  intmax_t;
+typedef __uintn_t(__INTMAX_WIDTH__) uintmax_t;
 
 /* C99 7.18.4 Macros for minimum-width integer constants.
  *

Modified: cfe/trunk/test/Preprocessor/stdint.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/stdint.c?rev=89459&r1=89458&r2=89459&view=diff

==============================================================================
--- cfe/trunk/test/Preprocessor/stdint.c (original)
+++ cfe/trunk/test/Preprocessor/stdint.c Fri Nov 20 10:37:35 2009
@@ -1158,6 +1158,35 @@
 // X86_64:INTMAX_C_(0) 0L
 // X86_64:UINTMAX_C_(0) 0UL
 //
+//
+// stdint.h forms several macro definitions by pasting together identifiers
+// to form names (eg. int32_t is formed from int ## 32 ## _t). The following 
+// case tests that these joining operations are performed correctly even if
+// the identifiers used in the operations (int, uint, _t, INT, UINT, _MIN,
+// _MAX, and _C(v)) are themselves macros.
+//
+// RUN: clang-cc -E -ffreestanding -Dint=a -Duint=b -D_t=c -DINT=d -DUINT=e -D_MIN=f -D_MAX=g '-D_C(v)=h' -triple=i386-none-none %s | FileCheck -check-prefix JOIN %s
+// JOIN:typedef int32_t intptr_t;
+// JOIN:typedef uint32_t uintptr_t;
+// JOIN:typedef int64_t intmax_t;
+// JOIN:typedef uint64_t uintmax_t;
+// TODO:INTPTR_MIN_ (-2147483647 -1)
+// TODO:INTPTR_MAX_ 2147483647
+// TODO:UINTPTR_MAX_ 4294967295U
+// TODO:PTRDIFF_MIN_ (-2147483647 -1)
+// TODO:PTRDIFF_MAX_ 2147483647
+// TODO:SIZE_MAX_ 4294967295U
+// TODO:INTMAX_MIN_ (-9223372036854775807LL -1)
+// TODO:INTMAX_MAX_ 9223372036854775807LL
+// TODO:UINTMAX_MAX_ 18446744073709551615ULL
+// TODO:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// TODO:SIG_ATOMIC_MAX_ 2147483647
+// TODO:WINT_MIN_ (-2147483647 -1)
+// TODO:WINT_MAX_ 2147483647
+// TODO:WCHAR_MAX_ 2147483647
+// TODO:WCHAR_MIN_ (-2147483647 -1)
+// TODO:INTMAX_C_(0) 0LL
+// TODO:UINTMAX_C_(0) 0ULL
 
 #include <stdint.h>
 





More information about the cfe-commits mailing list