diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-03-22 00:10:49 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-03-22 00:10:49 +0000 |
commit | daf2e1c636799535a7eb058ffab93cdf52f466cb (patch) | |
tree | e31ce8376a237d876f054322905cfb1cd958a16d /test/Modules | |
parent | f190f6b88e0648ebb5f49bab3c788e03e13b9069 (diff) |
<rdar://problem/13479214> Make Clang's <stddef.h> robust against system headers defining size_t/ptrdiff_t/wchar_t.
Clang's <stddef.h> provides definitions for the C standard library
types size_t, ptrdiff_t, and wchar_t. However, the system's C standard
library headers tend to provide the same typedefs, and the two
generally avoid each other using the macros
_SIZE_T/_PTRDIFF_T/_WCHAR_T. With modules, however, we need to see
*all* of the places where these types are defined, so provide the
typedefs (ignoring the macros) when modules are enabled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177686 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Modules')
-rw-r--r-- | test/Modules/Inputs/StdDef/module.map | 11 | ||||
-rw-r--r-- | test/Modules/Inputs/StdDef/other.h | 2 | ||||
-rw-r--r-- | test/Modules/Inputs/StdDef/size_t.h | 4 | ||||
-rw-r--r-- | test/Modules/stddef.m | 7 |
4 files changed, 24 insertions, 0 deletions
diff --git a/test/Modules/Inputs/StdDef/module.map b/test/Modules/Inputs/StdDef/module.map new file mode 100644 index 0000000000..69c69eac35 --- /dev/null +++ b/test/Modules/Inputs/StdDef/module.map @@ -0,0 +1,11 @@ +module StdDef { + module SizeT { + header "size_t.h" + export * + } + + module Other { + header "other.h" + export * + } +} diff --git a/test/Modules/Inputs/StdDef/other.h b/test/Modules/Inputs/StdDef/other.h new file mode 100644 index 0000000000..f29f6366cc --- /dev/null +++ b/test/Modules/Inputs/StdDef/other.h @@ -0,0 +1,2 @@ +#include <stddef.h> + diff --git a/test/Modules/Inputs/StdDef/size_t.h b/test/Modules/Inputs/StdDef/size_t.h new file mode 100644 index 0000000000..9ac61c5e0d --- /dev/null +++ b/test/Modules/Inputs/StdDef/size_t.h @@ -0,0 +1,4 @@ +#ifndef _SIZE_T +#define _SIZE_T +typedef __SIZE_TYPE__ size_t; +#endif diff --git a/test/Modules/stddef.m b/test/Modules/stddef.m new file mode 100644 index 0000000000..83f73f9d33 --- /dev/null +++ b/test/Modules/stddef.m @@ -0,0 +1,7 @@ +@import StdDef.Other; + +size_t getSize(); + +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/StdDef %s -verify +// expected-no-diagnostics |