In gcc/: 2010-11-03 Nicola Pero <nicola.pero@meta-innovation.com>

In gcc/:
2010-11-03  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-03  Nicola Pero  <nicola.pero@meta-innovation.com>

        Implemented -fobjc-std=objc1 flag.
        * c.opt (fobjc-std=objc1): New option.

In gcc/objc/:
2010-11-03  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-03  Nicola Pero  <nicola.pero@meta-innovation.com>

        Implemented -fobjc-std=objc1 flag.
        * objc.dg/fobjc-std-1.m: New.
        * obj-c++.dg/fobjc-std-1.mm: New.

From-SVN: r166246
This commit is contained in:
Nicola Pero 2010-11-03 13:39:39 +00:00 committed by Nicola Pero
parent 68a22980da
commit 22d8d61602
10 changed files with 244 additions and 18 deletions

View File

@ -1,3 +1,12 @@
2010-11-03 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-03 Richard Guenther <rguenther@suse.de>
PR middle-end/46241

View File

@ -1,3 +1,8 @@
2010-11-03 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.

View File

@ -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)

View File

@ -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 NeXT runtime; 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

View File

@ -209,11 +209,13 @@ no C++ language dialect options are given, is @option{-std=gnu++98}.
@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'' language
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/}

View File

@ -1,3 +1,23 @@
2010-11-03 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-03 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (maybe_make_artificial_property_decl): New.

View File

@ -686,9 +686,14 @@ objc_start_class_interface (tree klass, tree super_class,
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 categ,
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, tree decl,
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");
@ -1155,6 +1181,11 @@ objc_maybe_build_component_ref (tree object, tree property_ident)
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
@ -1346,6 +1377,9 @@ objc_add_method_declaration (bool is_class_method, tree decl, tree attributes)
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,
@ -6632,6 +6666,9 @@ objc_build_keyword_decl (tree key_name, tree arg_type,
{
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);
@ -9339,6 +9376,9 @@ objc_add_synthesize_declaration (location_t location, tree property_and_ivar_lis
{
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;
@ -9459,6 +9499,9 @@ objc_add_dynamic_declaration (location_t location, tree property_list)
{
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;
@ -12163,6 +12206,9 @@ objc_finish_foreach_loop (location_t location, tree object_expression, tree coll
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;

View File

@ -1,3 +1,9 @@
2010-11-03 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented -fobjc-std=objc1 flag.
* objc.dg/fobjc-std-1.m: New.
* obj-c++.dg/fobjc-std-1.mm: New.
2010-11-03 Richard Guenther <rguenther@suse.de>
PR middle-end/46241

View File

@ -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

View File

@ -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;
}