* ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1
@ 2010-11-02 10:07 Nicola Pero
2010-11-02 10:13 ` IainS
2010-11-02 10:21 ` Mike Stump
0 siblings, 2 replies; 8+ messages in thread
From: Nicola Pero @ 2010-11-02 10:07 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 3274 bytes --]
This patch:
* updates the documentation on the version of Objective-C/Objective-C++
supported by the compiler;
* adds a new -fobjc-std=objc1 option which causes the compiler to accept only
the Objective-C 1.0 syntax (which for clarity of definition I defined as the
Objective-C syntax accepted by GCC 4.0);
* adds testcases for the new option.
The reason that this new option is useful is that some projects have
a large Objective-C codebase and require the codebase to compile with different
versions of GCC, including old ones. It is handy to be able to have a flag
that will prevent people with new compilers from committing code that uses
a syntax not supported by old compilers.
Of course, the default is to allow all the Objective-C 2.0 extensions. This flag is
only for people who have a specific reason to disable the extensions. :-)
The option name itself is not set in stone; suggestions I welcome. I like
-fobjc-std=xxx (as opposed to, say, -fobjc-language-version=1 / -fobjc-language-version=2)
for consistency with -std=xxx and because we don't know how future versions of the language
may be named or presented so having a free string there helps to be adaptable (in the same
way as it works for -std=xxx in C/C++).
About the short string used to mean 'Objective-C 1.0', I chose 'objc1'. An alternative
would be choosing 'gcc40', so the option could become -fobjc-std=gcc40. That may be
more accurate, but less obvious (or maybe not).
I'm happy to take suggestions on that.
Else, Ok to commit to trunk ?
Thanks
In gcc/:
2010-11-02 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented -fobjc-std=objc1 flag.
* doc/invoke.texi (Option Summary): Document -fobjc-std=objc1
option.
* doc/standards.texi (Standards): Updated the section on
Objective-C; mention support for Objective-C 2.0 features and the
new -fstd-objc=objc1 flag to disable them.
In gcc/c-family/:
2010-11-02 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented -fobjc-std=objc1 flag.
* c.opt (fobjc-std=objc1): New option.
In gcc/objc/:
2010-11-02 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented -fobjc-std=objc1 flag.
* objc-act.c (objc_start_class_interface): If attributes are
specified when flag_objc1_only is set, print an error.
(objc_start_category_interface): Same change.
(objc_start_protocol): Same change.
(objc_add_method_declaration): Same change.
(objc_start_method_definition): Same change.
(objc_build_keyword_decl): Same change.
(objc_set_method_opt): If flag_objc1_only is set, print an error.
(objc_add_property_declaration): Same change.
(objc_add_synthesize_declaration): Same change.
(objc_add_dynamic_declaration): Same change.
(objc_finish_foreach_loop): Same change.
(objc_maybe_build_component_ref): If flag_objc1_only is set,
return immediately.
In gcc/testsuite/:
2010-11-02 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented -fobjc-std=objc1 flag.
* objc.dg/fobjc-std-1.mm: New.
* obj-c++.dg/fobjc-std-1.mm: New.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 17319 bytes --]
Index: gcc/doc/standards.texi
===================================================================
--- gcc/doc/standards.texi (revision 166154)
+++ gcc/doc/standards.texi (working copy)
@@ -209,11 +209,13 @@ no C++ language dialect options are given, is @opt
@cindex Objective-C++
GCC supports ``traditional'' Objective-C (also known as ``Objective-C
-1.0''), and contains support for the Objective-C exception and
-synchronization syntax. At the time of writing, it has no support for
-``Objective-C 2.0'' language extensions. GCC supports Objective-C++
-and features available in Objective-C are also available in
-Objective-C++@.
+1.0'') and contains support for the Objective-C exception and
+synchronization syntax. It has also support for a number of
+``Objective-C 2.0'' language extensions, including properties, fast
+enumeration (only for Objective-C), method attributes and the
+@@optional and @@required keywords in protocols. GCC supports
+Objective-C++ and features available in Objective-C are also available
+in Objective-C++@.
GCC by default uses the GNU Objective-C runtime library, which is part
of GCC and is not the same as the Apple/NeXT Objective-C runtime
@@ -242,12 +244,25 @@ not documentation on the newer ``Objective-C 2.0''
The Objective-C exception and synchronization syntax (that is, the
keywords @@try, @@throw, @@catch, @@finally and @@synchronized) is
-fully supported by GCC and is enabled with the option
+supported by GCC and is enabled with the option
@option{-fobjc-exceptions}. The syntax is briefly documented in this
manual and in the Objective-C 2.0 manuals from Apple.
-At the time of writing, GCC supports no Objective-C 2.0 features. The
-authoritative manual on Objective-C 2.0 is available from Apple:
+The Objective-C 2.0 language extensions and features are automatically
+enabled; they include properties (via the @@property, @@synthesize and
+@@dynamic keywords), fast enumeration (not available in
+Objective-C++), attributes for methods (such as deprecated, noreturn,
+sentinel, format), the unused attribute for method arguments, the
+@@package keyword for instance variables and the @@optional and
+@@required keywords in protocols. You can disable all these
+Objective-C 2.0 language extensions with the option
+@option{-fobjc-std=objc1}, which causes the compiler to recognize the
+same Objective-C language syntax recognized by GCC 4.0, and to produce
+an error if one of the new features is used.
+
+GCC has currently no support for non-fragile instance variables.
+
+The authoritative manual on Objective-C 2.0 is available from Apple:
@itemize
@item
@uref{http://developer.apple.com/@/mac/@/library/@/documentation/@/Cocoa/@/Conceptual/@/ObjectiveC/}
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi (revision 166154)
+++ gcc/doc/invoke.texi (working copy)
@@ -212,6 +212,7 @@ Objective-C and Objective-C++ Dialects}.
-fobjc-direct-dispatch @gol
-fobjc-exceptions @gol
-fobjc-gc @gol
+-fobjc-std=objc1 @gol
-freplace-objc-classes @gol
-fzero-link @gol
-gen-decls @gol
@@ -2591,6 +2592,17 @@ programs. This option is only available with the
GNU runtime has a different garbage collection implementation that
does not require special compiler flags.
+@item -fobjc-std=objc1
+@opindex fobjc-std
+Conform to the language syntax of Objective-C 1.0, the language
+recognized by GCC 4.0. This only affects the Objective-C additions to
+the C/C++ language; it does not affect conformance to C/C++ standards,
+which is controlled by the separate C/C++ dialect option flags. When
+this option is used with the Objective-C or Objective-C++ compiler,
+any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
+This is useful if you need to make sure that your Objective-C code can
+be compiled with older versions of GCC.
+
@item -freplace-objc-classes
@opindex freplace-objc-classes
Emit a special marker instructing @command{ld(1)} not to statically link in
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt (revision 166154)
+++ gcc/c-family/c.opt (working copy)
@@ -870,6 +870,10 @@ fobjc-sjlj-exceptions
ObjC ObjC++ Var(flag_objc_sjlj_exceptions) Init(-1)
Enable Objective-C setjmp exception handling runtime
+fobjc-std=objc1
+ObjC ObjC++ Var(flag_objc1_only)
+Conform to the Objective-C 1.0 language as implemented in GCC 4.0
+
fopenmp
C ObjC C++ ObjC++ Var(flag_openmp)
Enable OpenMP (implies -frecursive in Fortran)
Index: gcc/c-family/ChangeLog
===================================================================
--- gcc/c-family/ChangeLog (revision 166154)
+++ gcc/c-family/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2010-11-02 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Implemented -fobjc-std=objc1 flag.
+ * c.opt (fobjc-std=objc1): New option.
+
2010-11-01 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented format and noreturn attributes for Objective-C methods.
Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c (revision 166154)
+++ gcc/objc/objc-act.c (working copy)
@@ -686,9 +686,14 @@ objc_start_class_interface (tree klass, tree super
tree protos, tree attributes)
{
if (attributes)
- warning_at (input_location, OPT_Wattributes,
- "class attributes are not available in this version"
- " of the compiler, (ignored)");
+ {
+ if (flag_objc1_only)
+ error_at (input_location, "class attributes are not available in Objective-C 1.0");
+ else
+ warning_at (input_location, OPT_Wattributes,
+ "class attributes are not available in this version"
+ " of the compiler, (ignored)");
+ }
objc_interface_context
= objc_ivar_context
= start_class (CLASS_INTERFACE_TYPE, klass, super_class, protos);
@@ -700,9 +705,14 @@ objc_start_category_interface (tree klass, tree ca
tree protos, tree attributes)
{
if (attributes)
- warning_at (input_location, OPT_Wattributes,
- "category attributes are not available in this version"
- " of the compiler, (ignored)");
+ {
+ if (flag_objc1_only)
+ error_at (input_location, "category attributes are not available in Objective-C 1.0");
+ else
+ warning_at (input_location, OPT_Wattributes,
+ "category attributes are not available in this version"
+ " of the compiler, (ignored)");
+ }
objc_interface_context
= start_class (CATEGORY_INTERFACE_TYPE, klass, categ, protos);
objc_ivar_chain
@@ -713,9 +723,14 @@ void
objc_start_protocol (tree name, tree protos, tree attributes)
{
if (attributes)
- warning_at (input_location, OPT_Wattributes,
- "protocol attributes are not available in this version"
- " of the compiler, (ignored)");
+ {
+ if (flag_objc1_only)
+ error_at (input_location, "protocol attributes are not available in Objective-C 1.0");
+ else
+ warning_at (input_location, OPT_Wattributes,
+ "protocol attributes are not available in this version"
+ " of the compiler, (ignored)");
+ }
objc_interface_context
= start_protocol (PROTOCOL_INTERFACE_TYPE, name, protos);
objc_method_optional_flag = false;
@@ -783,13 +798,21 @@ void
objc_set_visibility (objc_ivar_visibility_kind visibility)
{
if (visibility == OBJC_IVAR_VIS_PACKAGE)
- warning (0, "%<@package%> presently has the same effect as %<@public%>");
+ {
+ if (flag_objc1_only)
+ error ("%<@package%> is not available in Objective-C 1.0");
+ else
+ warning (0, "%<@package%> presently has the same effect as %<@public%>");
+ }
objc_ivar_visibility = visibility;
}
void
objc_set_method_opt (bool optional)
{
+ if (flag_objc1_only)
+ error_at (input_location, "@optional/@required are not available in Objective-C 1.0");
+
objc_method_optional_flag = optional;
if (!objc_interface_context
|| TREE_CODE (objc_interface_context) != PROTOCOL_INTERFACE_TYPE)
@@ -827,6 +850,9 @@ objc_add_property_declaration (location_t location
bool property_readonly = false;
objc_property_assign_semantics property_assign_semantics = OBJC_PROPERTY_ASSIGN;
+ if (flag_objc1_only)
+ error_at (input_location, "%<@property%> is not available in Objective-C 1.0");
+
if (parsed_property_readonly && parsed_property_readwrite)
{
error_at (location, "%<readonly%> attribute conflicts with %<readwrite%> attribute");
@@ -1069,6 +1095,11 @@ objc_maybe_build_component_ref (tree object, tree
tree x = NULL_TREE;
tree rtype;
+ /* If we are in Objective-C 1.0 mode, properties are not
+ available. */
+ if (flag_objc1_only)
+ return NULL_TREE;
+
/* Try to determine quickly if 'object' is an Objective-C object or
not. If not, return. */
if (object == NULL_TREE || object == error_mark_node
@@ -1232,6 +1263,9 @@ objc_add_method_declaration (bool is_class_method,
fatal_error ("method declaration not in @interface context");
}
+ if (flag_objc1_only && attributes)
+ error_at (input_location, "method attributes are not available in Objective-C 1.0");
+
objc_decl_method_attributes (&decl, attributes, 0);
objc_add_method (objc_interface_context,
decl,
@@ -6518,6 +6552,9 @@ objc_build_keyword_decl (tree key_name, tree arg_t
{
tree keyword_decl;
+ if (flag_objc1_only && attributes)
+ error_at (input_location, "method argument attributes are not available in Objective-C 1.0");
+
/* If no type is specified, default to "id". */
arg_type = adjust_type_for_id_default (arg_type);
@@ -9225,6 +9262,9 @@ objc_add_synthesize_declaration (location_t locati
{
tree interface, chain;
+ if (flag_objc1_only)
+ error_at (input_location, "%<@synthesize%> is not available in Objective-C 1.0");
+
if (property_and_ivar_list == error_mark_node)
return;
@@ -9345,6 +9385,9 @@ objc_add_dynamic_declaration (location_t location,
{
tree interface, chain;
+ if (flag_objc1_only)
+ error_at (input_location, "%<@dynamic%> is not available in Objective-C 1.0");
+
if (property_list == error_mark_node)
return;
@@ -12049,6 +12092,9 @@ objc_finish_foreach_loop (location_t location, tre
tree t;
int i;
+ if (flag_objc1_only)
+ error_at (location, "fast enumeration is not available in Objective-C 1.0");
+
if (object_expression == error_mark_node)
return;
Index: gcc/objc/ChangeLog
===================================================================
--- gcc/objc/ChangeLog (revision 166154)
+++ gcc/objc/ChangeLog (working copy)
@@ -1,3 +1,23 @@
+2010-11-02 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Implemented -fobjc-std=objc1 flag.
+ * objc-act.c (objc_start_class_interface): If attributes are
+ specified when flag_objc1_only is set, print an error.
+ (objc_start_category_interface): Same change.
+ (objc_start_protocol): Same change.
+ (objc_add_method_declaration): Same change.
+ (objc_start_method_definition): Same change.
+ (objc_build_keyword_decl): Same change.
+ (objc_set_visibility): If OBJC_IVAR_VIS_PACKAGE is used when
+ flag_objc1_set is set, print an error.
+ (objc_set_method_opt): If flag_objc1_only is set, print an error.
+ (objc_add_property_declaration): Same change.
+ (objc_add_synthesize_declaration): Same change.
+ (objc_add_dynamic_declaration): Same change.
+ (objc_finish_foreach_loop): Same change.
+ (objc_maybe_build_component_ref): If flag_objc1_only is set,
+ return immediately.
+
2010-11-01 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented format and noreturn attributes for Objective-C methods.
Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog (revision 166154)
+++ gcc/ChangeLog (working copy)
@@ -1,3 +1,12 @@
+2010-11-02 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Implemented -fobjc-std=objc1 flag.
+ * doc/invoke.texi (Option Summary): Document -fobjc-std=objc1
+ option.
+ * doc/standards.texi (Standards): Updated the section on
+ Objective-C; mention support for Objective-C 2.0 features and the
+ new -fstd-objc=objc1 flag to disable them.
+
2010-11-01 Paul Koning <ni1d@arrl.net>
* config/pdp11/pdp11.md: Use iterators.
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (revision 166154)
+++ gcc/testsuite/ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2010-11-02 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Implemented -fobjc-std=objc1 flag.
+ * objc.dg/fobjc-std-1.mm: New.
+ * obj-c++.dg/fobjc-std-1.mm: New.
+
2010-11-01 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented format and noreturn attributes for Objective-C methods.
Index: gcc/testsuite/objc.dg/fobjc-std-1.m
===================================================================
--- gcc/testsuite/objc.dg/fobjc-std-1.m (revision 0)
+++ gcc/testsuite/objc.dg/fobjc-std-1.m (revision 0)
@@ -0,0 +1,54 @@
+/* Test warnings when using -fobjc-std=objc1. */
+/* { dg-do compile } */
+/* { dg-options "-fobjc-std=objc1" } */
+
+#include <objc/objc.h>
+
+__attribute__ ((deprecated))
+@interface MyRootClass
+{ /* { dg-error "class attributes are not available in Objective.C 1.0" } */
+ Class isa;
+@package /* { dg-error "not available in Objective.C 1.0" } */
+ int a;
+ int b;
+}
++ (id) alloc __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
+- (id) init;
+- (id) testMe: (id) __attribute__((unused)) argument; /* { dg-error "not available in Objective.C 1.0" } */
+@property (nonatomic) int a; /* { dg-error "not available in Objective.C 1.0" } */
+@property (nonatomic) int b; /* { dg-error "not available in Objective.C 1.0" } */
+@end
+
+@implementation MyRootClass
++ (id) alloc { return self; }
+- (id) init { return self; }
+- (id) testMe: (id) __attribute__((unused)) argument { return self; } /* { dg-error "not available in Objective.C 1.0" } */
+@synthesize a; /* { dg-error "not available in Objective.C 1.0" } */
+@dynamic b; /* { dg-error "not available in Objective.C 1.0" } */
+@end
+
+__attribute__ ((deprecated))
+@protocol MyProtocol
+- (id) test; /* { dg-error "protocol attributes are not available in Objective.C 1.0" } */
+@required /* { dg-error "not available in Objective.C 1.0" } */
+- (id) variable __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
+@optional /* { dg-error "not available in Objective.C 1.0" } */
+@end
+
+@interface MyRootClass (NSFastEnumeration)
+- (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
+ objects:(id *)stackbuf
+ count:(unsigned int)len;
+@end
+
+@class NSArray;
+
+int array_length (NSArray *array)
+{
+ int i = 0;
+
+ for (id object in array) /* { dg-error "not available in Objective.C 1.0" } */
+ i++;
+
+ return i;
+}
Index: gcc/testsuite/obj-c++.dg/fobjc-std-1.mm
===================================================================
--- gcc/testsuite/obj-c++.dg/fobjc-std-1.mm (revision 0)
+++ gcc/testsuite/obj-c++.dg/fobjc-std-1.mm (revision 0)
@@ -0,0 +1,55 @@
+/* Test warnings when using -fobjc-std=objc1. */
+/* { dg-do compile } */
+/* { dg-options "-fobjc-std=objc1" } */
+
+#include <objc/objc.h>
+
+__attribute__ ((deprecated))
+@interface MyRootClass /* { dg-error "class attributes are not available in Objective.C 1.0" } */
+{
+ Class isa; /* { dg-error ".@package. is not available in Objective.C 1.0" } */
+@package
+ int a;
+ int b;
+}
++ (id) alloc __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
+- (id) init;
+- (id) testMe: (id) __attribute__((unused)) argument; /* { dg-error "not available in Objective.C 1.0" } */
+@property (nonatomic) int a; /* { dg-error "not available in Objective.C 1.0" } */
+@property (nonatomic) int b; /* { dg-error "not available in Objective.C 1.0" } */
+@end
+
+@implementation MyRootClass
++ (id) alloc { return self; }
+- (id) init { return self; }
+- (id) testMe: (id) __attribute__((unused)) argument { return self; } /* { dg-error "not available in Objective.C 1.0" } */
+@synthesize a; /* { dg-error "not available in Objective.C 1.0" } */
+@dynamic b; /* { dg-error "not available in Objective.C 1.0" } */
+@end
+
+__attribute__ ((deprecated))
+@protocol MyProtocol /* { dg-error "protocol attributes are not available in Objective.C 1.0" } */
+
+@required /* { dg-error "not available in Objective.C 1.0" } */
+- (id) variable __attribute__ ((deprecated)); /* { dg-error "not available in Objective.C 1.0" } */
+@optional /* { dg-error "not available in Objective.C 1.0" } */
+@end
+#if 0 /* fast enumeration is not implemented even in Objective-C 2.0 */
+@interface MyRootClass (NSFastEnumeration)
+- (unsigned long)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state
+ objects:(id *)stackbuf
+ count:(unsigned int)len;
+@end
+
+@class NSArray;
+
+int array_length (NSArray *array)
+{
+ int i = 0;
+
+ for (id object in array) /* dg-error "not available in Objective.C 1.0" */
+ i++;
+
+ return i;
+}
+#endif
\ No newline at end of file
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1
2010-11-02 10:07 ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1 Nicola Pero
@ 2010-11-02 10:13 ` IainS
2010-11-02 13:48 ` Nicola Pero
2010-11-02 10:21 ` Mike Stump
1 sibling, 1 reply; 8+ messages in thread
From: IainS @ 2010-11-02 10:13 UTC (permalink / raw)
To: Nicola Pero; +Cc: gcc-patches
On 2 Nov 2010, at 09:42, Nicola Pero wrote:
> * adds a new -fobjc-std=objc1 option which causes the compiler to
> accept only
> the Objective-C 1.0 syntax (which for clarity of definition I
> defined as the
> Objective-C syntax accepted by GCC 4.0);
as we've discussed before, I think this is a very good idea ...
(we will also probably need an -fobjc-abi=)
> The option name itself is not set in stone; suggestions I welcome.
> I like
> -fobjc-std=xxx (as opposed to, say, -fobjc-language-version=1 / -
> fobjc-language-version=2)
> for consistency with -std=xxx and because we don't know how future
> versions of the language
> may be named or presented so having a free string there helps to be
> adaptable (in the same
> way as it works for -std=xxx in C/C++).
.. the only issue with using 'std' is that there are no 'standards' as
such - on the NeXT side the best we could do would be to refer to the
ObjC1 and ObjC2 documents and XCode release notes.
I am not passionately worried by this - but would vote in favor of -
fobjc-language= or even -fobjc-lang= ( to keep the typing to a minimum)
An enumerated short string is much more flexible than a number.
> About the short string used to mean 'Objective-C 1.0', I chose
> 'objc1'. An alternative
> would be choosing 'gcc40', so the option could become -fobjc-
> std=gcc40. That may be
> more accurate, but less obvious (or maybe not).
This looks good and should encompass the pre-Darwin-9 language variant
too.
I'm not sure that naming by gcc release would help the User much - is
there enough objc doc in the tree to be clear about what functionality
is included?
If we needed to make it more fine-grained, for NeXT the logical thing
would be to name by XCode release - since then the documentation is
available (in public).
[but your present suggestion is perfectly good for current needs :-)]
BTW, I also noticed that Darwin-8/NeXT cannot support object
iterators (missing a function in the runtime).
We might need a means to disable that.
cheers,
Iain
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1
2010-11-02 10:07 ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1 Nicola Pero
2010-11-02 10:13 ` IainS
@ 2010-11-02 10:21 ` Mike Stump
1 sibling, 0 replies; 8+ messages in thread
From: Mike Stump @ 2010-11-02 10:21 UTC (permalink / raw)
To: Nicola Pero; +Cc: gcc-patches
On Nov 2, 2010, at 2:42 AM, Nicola Pero wrote:
> Ok to commit to trunk ?
Ok.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1
2010-11-02 10:13 ` IainS
@ 2010-11-02 13:48 ` Nicola Pero
2010-11-02 14:10 ` IainS
0 siblings, 1 reply; 8+ messages in thread
From: Nicola Pero @ 2010-11-02 13:48 UTC (permalink / raw)
To: IainS; +Cc: gcc-patches
> .. the only issue with using 'std' is that there are no 'standards' as
> such
Yes. :-)
But I'd like to use "std" in the name because it does the same things that
-std=... does for C/C++: it makes the compiler conform to a certain dialect
of the language. In this case, the dialect ("Objective-C 1.0") is specified
by referring to a reference implementation (GCC 4.0). I'd say that is the
same as what an option like -std=gnu89 does. Most GCC users are aware of
-std=c90 and similar and it makes sense for them to have an option with
a similar name (-fobjc-std=...) for the Objective-C dialect. (it could be
argued that it should be -objc-std=... to be more similar to -std=...)
If we don't want to use "std", maybe I'd be happy with -fobjc-dialect=xxx.
Else, we can always stick with -fobjc-std=objc1.
Thanks
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1
2010-11-02 13:48 ` Nicola Pero
@ 2010-11-02 14:10 ` IainS
2010-11-02 17:59 ` Mike Stump
2010-11-02 19:19 ` Nicola Pero
0 siblings, 2 replies; 8+ messages in thread
From: IainS @ 2010-11-02 14:10 UTC (permalink / raw)
To: Nicola Pero; +Cc: gcc-patches
On 2 Nov 2010, at 13:44, Nicola Pero wrote:
>
>> .. the only issue with using 'std' is that there are no 'standards'
>> as
>> such
>
> Yes. :-)
>
> But I'd like to use "std" in the name because it does the same
> things that
> -std=... does for C/C++: it makes the compiler conform to a certain
> dialect
> of the language. In this case, the dialect ("Objective-C 1.0") is
> specified
> by referring to a reference implementation (GCC 4.0). I'd say that
> is the
> same as what an option like -std=gnu89 does. Most GCC users are
> aware of
> -std=c90 and similar and it makes sense for them to have an option
> with
> a similar name (-fobjc-std=...) for the Objective-C dialect. (it
> could be
> argued that it should be -objc-std=... to be more similar to -std=...)
>
> If we don't want to use "std", maybe I'd be happy with -fobjc-
> dialect=xxx.
Mike OK'd it already ;-)
Iain
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1
2010-11-02 14:10 ` IainS
@ 2010-11-02 17:59 ` Mike Stump
2010-11-02 19:19 ` Nicola Pero
1 sibling, 0 replies; 8+ messages in thread
From: Mike Stump @ 2010-11-02 17:59 UTC (permalink / raw)
To: IainS; +Cc: Nicola Pero, gcc-patches
On Nov 2, 2010, at 6:47 AM, IainS wrote:
>> If we don't want to use "std", maybe I'd be happy with -fobjc-dialect=xxx.
>
> Mike OK'd it already ;-)
Yeah, but, I'd pre-approve a patch to change it to use -std. I think using the option that selects the language to select the language, is kinda straight forward. I don't recall a compelling argument against. I could have approved with that change, but I don't feel compelled to reject just because the option might be slightly less optimal.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1
2010-11-02 14:10 ` IainS
2010-11-02 17:59 ` Mike Stump
@ 2010-11-02 19:19 ` Nicola Pero
2010-11-02 20:03 ` IainS
1 sibling, 1 reply; 8+ messages in thread
From: Nicola Pero @ 2010-11-02 19:19 UTC (permalink / raw)
To: IainS; +Cc: gcc-patches
>> If we don't want to use "std", maybe I'd be happy with -fobjc-
>> dialect=xxx.
>
> Mike OK'd it already ;-)
Yes, but that doesn't mean we can't discuss it further :-)
I think Mike approved it because the patch is good enough to go in (which
it is); if we come up with something better, or if someone has good objections,
we can always submit a revised patch, or a followup patch.
Having discussed it for a bit, I actually now quite like the original choice of -fobjc-std=objc1.
The reasons are:
* it is similar to -fobjc-exceptions, which enables/disables @synchronized, @try/@catch/@finally.
So you'll find it in the same place in the GCC manual, and consistently starts with "-fobjc-" like
the new option and the other ObjC language options;
* it is similar to -std=xxx, but orthogonal to it, so you can for example use
"-std=c99 -fobjc-std=objc1" or "-std=gnu89 -fobjc-std=objc1" and get a different language (people
who use these flags can get very hot about these things; if we have orthogonal flags for C/C++ and
ObjC, we can make them happy no matter what combination they ask for);
* it takes a short keyword as argument, so it should be robust if we need to add other language
dialects in the future;
* inside the GCC source code, I used "if (flag_objc1_only)" to detect the case that Objective-C 1.0
was requested (which should be fairly self-explanatory, much more self-explanatory that "if (flag_gcc40)"),
and I like the option having the same name (objc1) in the command-line option so it's easy to make
the association between "if (flag_objc1_only)" and "-fobjc-std=objc1"
I guess the only other main contendents would be -fobjc1-only (which I actually like to as it is clear
and immediately maps to "if (objc1_only)" in the code), but then if/when the language changes again
we'd have to add another flag, and it's neater to have just one (-fobjc-std=...) with an enumeration
of the values.
Anyway, I'll wait another day or so for further comments or suggestions (which are very welcome)
before committing.
Thanks
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1
2010-11-02 19:19 ` Nicola Pero
@ 2010-11-02 20:03 ` IainS
0 siblings, 0 replies; 8+ messages in thread
From: IainS @ 2010-11-02 20:03 UTC (permalink / raw)
To: Nicola Pero; +Cc: gcc-patches
On 2 Nov 2010, at 18:58, Nicola Pero wrote:
>
>>> If we don't want to use "std", maybe I'd be happy with -fobjc-
>>> dialect=xxx.
>>
>> Mike OK'd it already ;-)
>
> Yes, but that doesn't mean we can't discuss it further :-)
indeed .. :-)
.. and rest assured if I feel strongly about something .. I will
argue ;)
but I'm happy to go with the consensus.
> I think Mike approved it because the patch is good enough to go in
> (which
> it is); if we come up with something better, or if someone has good
> objections,
> we can always submit a revised patch, or a followup patch.
I was nit-picking really (re. no actual standards) ...
... in which respect it would differ from the -std= option.
> Having discussed it for a bit, I actually now quite like the
> original choice of -fobjc-std=objc1.
> The reasons are:
I agree, -fobjc-std= or -objc-std= is clearer than -fobjc-dialect
(which would be confusing, I suspect).
> * it is similar to -fobjc-exceptions, which enables/disables
> @synchronized, @try/@catch/@finally.
> So you'll find it in the same place in the GCC manual, and
> consistently starts with "-fobjc-" like
> the new option and the other ObjC language options;
>
> * it is similar to -std=xxx, but orthogonal to it, so you can for
> example use
> "-std=c99 -fobjc-std=objc1" or "-std=gnu89 -fobjc-std=objc1" and get
> a different language (people
> who use these flags can get very hot about these things; if we have
> orthogonal flags for C/C++ and
> ObjC, we can make them happy no matter what combination they ask for);
>
> * it takes a short keyword as argument, so it should be robust if we
> need to add other language
> dialects in the future;
>
> * inside the GCC source code, I used "if (flag_objc1_only)" to
> detect the case that Objective-C 1.0
> was requested (which should be fairly self-explanatory, much more
> self-explanatory that "if (flag_gcc40)"),
> and I like the option having the same name (objc1) in the command-
> line option so it's easy to make
> the association between "if (flag_objc1_only)" and "-fobjc-std=objc1"
yes - choosing the tags for ready cross-reference & understanding is
important.
> I guess the only other main contendents would be -fobjc1-only (which
> I actually like to as it is clear
> and immediately maps to "if (objc1_only)" in the code), but then if/
> when the language changes again
> we'd have to add another flag, and it's neater to have just one (-
> fobjc-std=...) with an enumeration
> of the values.
I agree 100% about the desirability of an enum - once can then switch
on lang variant etc.
we def. don't want to proliferate flags.
Hm - how does -std= do it ?
cheers
Iain
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-11-02 19:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-02 10:07 ObjC/ObjC++: updated documentation on supported standards, and added -fobjc-std=objc1 Nicola Pero
2010-11-02 10:13 ` IainS
2010-11-02 13:48 ` Nicola Pero
2010-11-02 14:10 ` IainS
2010-11-02 17:59 ` Mike Stump
2010-11-02 19:19 ` Nicola Pero
2010-11-02 20:03 ` IainS
2010-11-02 10:21 ` Mike Stump
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).