]> granicus.if.org Git - clang/commitdiff
[driver] Emit an error when trying to use ARC on macosx earlier than 10.6
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 29 Feb 2012 03:43:52 +0000 (03:43 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 29 Feb 2012 03:43:52 +0000 (03:43 +0000)
rdar://10459258

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

include/clang/Basic/DiagnosticDriverKinds.td
include/clang/Driver/ToolChain.h
lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
lib/Driver/Tools.cpp
test/Driver/arc.c

index 021de8869e45f6cfe081c78d9cb9001cbcd38933..aaf524105637f0fdbbaa259805e4af84ea74882f 100644 (file)
@@ -93,6 +93,8 @@ def err_drv_objc_gc_arr : Error<
   "cannot specify both '-fobjc-arc' and '%0'">;
 def err_arc_nonfragile_abi : Error<
   "-fobjc-arc is not supported with fragile abi">;
+def err_arc_unsupported : Error<
+  "-fobjc-arc is not supported on current deployment target">;
 def err_drv_mg_requires_m_or_mm : Error<
   "option '-MG' requires '-M' or '-MM'">;
 
index 4f3a3be68136bf996d8dc36bcbcdcebd324ff673..c35cf673dee495ea8cffa37cdba17249d70419dd 100644 (file)
@@ -184,6 +184,9 @@ public:
   /// Does this tool chain support Objective-C garbage collection.
   virtual bool SupportsObjCGC() const { return true; }
 
+  /// Does this tool chain support Objective-C ARC.
+  virtual bool SupportsObjCARC() const { return true; }
+
   /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
   /// compile unit information.
   virtual bool UseDwarfDebugFlags() const { return false; }
index 14c87d8216f3f0bc7e39fd8968842969aa657eba..e125ab78f4e10eba764eedf4b9b576e7c0feda1e 100644 (file)
@@ -1019,6 +1019,10 @@ bool Darwin::SupportsObjCGC() const {
   return !isTargetIPhoneOS();
 }
 
+bool Darwin::SupportsObjCARC() const {
+  return isTargetIPhoneOS() || !isMacosxVersionLT(10, 6);
+}
+
 std::string
 Darwin_Generic_GCC::ComputeEffectiveClangTriple(const ArgList &Args,
                                                 types::ID InputType) const {
index 0fb213828ff9e6780637e0c0864b6d7caea5eb1b..0d591107de81dbd61886dba25612195ce60cec49 100644 (file)
@@ -379,6 +379,8 @@ public:
 
   virtual bool SupportsObjCGC() const;
 
+  virtual bool SupportsObjCARC() const;
+
   virtual bool UseDwarfDebugFlags() const;
 
   virtual bool UseSjLjExceptions() const;
index 14fb9cb7188e3449d2e60a367ed7065f535e2413..c5caaf024f73fe14e7eb973ab4a35b39a4a02aea 100644 (file)
@@ -2225,6 +2225,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // NOTE: This logic is duplicated in ToolChains.cpp.
   bool ARC = isObjCAutoRefCount(Args);
   if (ARC) {
+    if (!getToolChain().SupportsObjCARC())
+      D.Diag(diag::err_arc_unsupported);
+
     CmdArgs.push_back("-fobjc-arc");
 
     // FIXME: It seems like this entire block, and several around it should be
index 96f03656e6ea4b6dca10e1eab1a983b231aa58a9..f2c1127116a057a846880eda3e4596641801bee7 100644 (file)
@@ -1,8 +1,9 @@
-// RUN: %clang -ObjC -target i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -x objective-c -target i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -x objective-c++ -target i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -x c -target i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
-// RUN: %clang -x c++ -target i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
+// RUN: %clang -ObjC -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -x objective-c -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -x objective-c++ -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -x c -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
+// RUN: %clang -x c++ -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
+// RUN: %clang -x objective-c -target x86_64-apple-darwin11 -mmacosx-version-min=10.5 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix UNSUPPORTED %s
 
 // Just to test clang is working.
 # foo
@@ -12,3 +13,5 @@
 
 // NOTOBJC-NOT: error: -fobjc-arc is not supported with fragile abi
 // NOTOBJC: invalid preprocessing directive
+
+// UNSUPPORTED: error: -fobjc-arc is not supported on current deployment target