r180918 - Make sure we define wchar_t related macros correctly in -fms-extensions mode.
Hans Wennborg
hans at hanshq.net
Thu May 2 06:12:32 PDT 2013
Author: hans
Date: Thu May 2 08:12:32 2013
New Revision: 180918
URL: http://llvm.org/viewvc/llvm-project?rev=180918&view=rev
Log:
Make sure we define wchar_t related macros correctly in -fms-extensions mode.
This adds a test to make sure we define _WCHAR_T_DEFINED and
_NATIVE_WCHAR_T_DEFINED correctly in the preprocessor, and updates
stddef.h to set it when typedeffing wchar_t.
Added:
cfe/trunk/test/Headers/ms-wchar.c (with props)
Modified:
cfe/trunk/lib/Headers/stddef.h
cfe/trunk/test/Preprocessor/init.c
Modified: cfe/trunk/lib/Headers/stddef.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/stddef.h?rev=180918&r1=180917&r2=180918&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/stddef.h (original)
+++ cfe/trunk/lib/Headers/stddef.h Thu May 2 08:12:32 2013
@@ -58,6 +58,9 @@ typedef __SIZE_TYPE__ rsize_t;
#if !defined(_WCHAR_T) || __has_feature(modules)
#if !__has_feature(modules)
#define _WCHAR_T
+#if defined(_MSC_EXTENSIONS)
+#define _WCHAR_T_DEFINED
+#endif
#endif
typedef __WCHAR_TYPE__ wchar_t;
#endif
Added: cfe/trunk/test/Headers/ms-wchar.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-wchar.c?rev=180918&view=auto
==============================================================================
--- cfe/trunk/test/Headers/ms-wchar.c (added)
+++ cfe/trunk/test/Headers/ms-wchar.c Thu May 2 08:12:32 2013
@@ -0,0 +1,15 @@
+// RUN: %clang -fsyntax-only -target i386-pc-win32 %s
+
+#if defined(_WCHAR_T_DEFINED)
+#error "_WCHAR_T_DEFINED should not be defined in C99"
+#endif
+
+#include <stddef.h>
+
+#if !defined(_WCHAR_T_DEFINED)
+#error "_WCHAR_T_DEFINED should have been set by stddef.h"
+#endif
+
+#if defined(_NATIVE_WCHAR_T_DEFINED)
+#error "_NATIVE_WCHAR_T_DEFINED should not be defined"
+#endif
Propchange: cfe/trunk/test/Headers/ms-wchar.c
------------------------------------------------------------------------------
svn:eol-style = LF
Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=180918&r1=180917&r2=180918&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu May 2 08:12:32 2013
@@ -88,10 +88,24 @@
// C94:#define __STDC_VERSION__ 199409L
//
//
-// RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -fobjc-runtime=gcc -E -dM < /dev/null | FileCheck -check-prefix MSEXT %s
+// RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -check-prefix MSEXT %s
//
// MSEXT-NOT:#define __STDC__
// MSEXT:#define _INTEGRAL_MAX_BITS 64
+// MSEXT-NOT:#define _NATIVE_WCHAR_T_DEFINED 1
+// MSEXT-NOT:#define _WCHAR_T_DEFINED 1
+//
+//
+// RUN: %clang_cc1 -x c++ -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -check-prefix MSEXT-CXX %s
+//
+// MSEXT-CXX:#define _NATIVE_WCHAR_T_DEFINED 1
+// MSEXT-CXX:#define _WCHAR_T_DEFINED 1
+//
+//
+// RUN: %clang_cc1 -x c++ -fno-wchar -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -check-prefix MSEXT-CXX-NOWCHAR %s
+//
+// MSEXT-CXX-NOWCHAR-NOT:#define _NATIVE_WCHAR_T_DEFINED 1
+// MSEXT-CXX-NOWCHAR-NOT:#define _WCHAR_T_DEFINED 1
//
//
// RUN: %clang_cc1 -x objective-c -E -dM < /dev/null | FileCheck -check-prefix OBJC %s
More information about the cfe-commits
mailing list