]> granicus.if.org Git - clang/commitdiff
size_t on Darwin AAPCS targets is "unsigned long". <rdar://problem/14136459>
authorBob Wilson <bob.wilson@apple.com>
Tue, 18 Jun 2013 05:36:04 +0000 (05:36 +0000)
committerBob Wilson <bob.wilson@apple.com>
Tue, 18 Jun 2013 05:36:04 +0000 (05:36 +0000)
Some embedded targets use ARM's AAPCS with iOS header files that define size_t
as unsigned long, which conflicts with the usual AAPCS definition of size_t
as unsigned int.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184171 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
test/Sema/arm-darwin-aapcs.cpp [new file with mode: 0644]

index 4e2d223c6bfa3be06c36c2e226daa61d0c351a9d..744a437fde5d0556a536186c5a7bcf84e9c762c7 100644 (file)
@@ -3642,6 +3642,9 @@ public:
 
       // FIXME: Override "preferred align" for double and long long.
     } else if (Name == "aapcs" || Name == "aapcs-vfp") {
+      // size_t is unsigned long on Darwin.
+      if (getTriple().isOSDarwin())
+        SizeType = UnsignedLong;
       IsAAPCS = true;
       // FIXME: Enumerated types are variable width in straight AAPCS.
     } else if (Name == "aapcs-linux") {
diff --git a/test/Sema/arm-darwin-aapcs.cpp b/test/Sema/arm-darwin-aapcs.cpp
new file mode 100644 (file)
index 0000000..1359a1d
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple thumbv7-apple-ios -target-abi aapcs -verify -fsyntax-only
+// expected-no-diagnostics
+
+// ARM's AAPCS normally has size_t defined as unsigned int, but on Darwin
+// some embedded targets use AAPCS with the iOS header files, which define
+// size_t as unsigned long.  Make sure that works.
+typedef unsigned long size_t;
+void* malloc(size_t);
+void* operator new(size_t size)
+{
+  return (malloc(size));
+}