While doing some wider testing on a patch to remove a build warning, I noticed
we were missing a check for the case that user's ABI version was set > 2 and
the codegen was for 64 bit.

Fixed thus,
tested on x86_64-dawin16,
Applied to mainline,
thanks
Iain

gcc/ChangeLog:

2019-10-09  Iain Sandoe  <i...@sandoe.co.uk>

        * config/darwin.c (darwin_override_options): Make the check for
        Objective-C ABI version more specific for 64bit code.

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 35d0444b5c..f490f622fc 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3114,18 +3114,19 @@ darwin_override_options (void)
                                : (generating_for_darwin_version >= 9) ? 1
                                                                       : 0);
 
-  /* Objective-C family ABI 2 is only valid for next/m64 at present.  */
   if (global_options_set.x_flag_objc_abi && flag_next_runtime)
     {
-      if (TARGET_64BIT && global_options.x_flag_objc_abi < 2)
-       error_at (UNKNOWN_LOCATION, "%<-fobjc-abi-version%> must be greater"
-                                   " than or equal to 2 for %<-m64%> targets"
-                                   " with %<-fnext-runtime%>");
-      if (!TARGET_64BIT && global_options.x_flag_objc_abi >= 2)
-       error_at (UNKNOWN_LOCATION, "%<-fobjc-abi-version%> %d is not"
-                                   " supported on %<-m32%> targets with"
-                                   " %<-fnext-runtime%>",
-                                   global_options.x_flag_objc_abi);
+      if (TARGET_64BIT && global_options.x_flag_objc_abi != 2)
+       /* The Objective-C family ABI 2 is the only valid version NeXT/m64.  */
+       error_at (UNKNOWN_LOCATION,
+                 "%<-fobjc-abi-version%> 2 must be used for 64 bit targets"
+                 " with %<-fnext-runtime%>");
+      else if (!TARGET_64BIT && global_options.x_flag_objc_abi >= 2)
+       /* ABI versions 0 and 1 are the only valid versions NeXT/m32.  */
+       error_at (UNKNOWN_LOCATION,
+                 "%<-fobjc-abi-version%> %d is not supported for 32 bit"
+                 " targets with %<-fnext-runtime%>",
+                 global_options.x_flag_objc_abi);
     }
 
   /* Don't emit DWARF3/4 unless specifically selected.  This is a

Reply via email to