c-parse.in (designator): Enable designated initializers if ObjC.
authorZiemowit Laski <zlaski@apple.com>
Tue, 2 Jul 2002 21:59:34 +0000 (21:59 +0000)
committerStan Shebs <shebs@gcc.gnu.org>
Tue, 2 Jul 2002 21:59:34 +0000 (21:59 +0000)
2002-07-02  Ziemowit Laski  <zlaski@apple.com>

* c-parse.in (designator): Enable designated initializers if ObjC.
(objcmessageexpr): Remove references to objc_receiver_context.
* objc/objc-act.h (objc_receiver_context): Remove decl.
* objc/objc-act.c (objc_receiver_context): Remove.
(lookup_objc_ivar): Test objc_method_context instead of
objc_receiver_context.

2002-07-02  Ziemowit Laski  <zlaski@apple.com>

* objc.dg/desig-init-1.m: New test.

From-SVN: r55192

gcc/ChangeLog
gcc/c-parse.in
gcc/objc/objc-act.c
gcc/objc/objc-act.h
gcc/testsuite/ChangeLog
gcc/testsuite/objc.dg/desig-init-1.m [new file with mode: 0644]

index e7a81de4c6ae8d531adca8b86c9484532566de58..18bbcdbfd0755a5a5fe9a1aa13a27e13380f7d4c 100644 (file)
@@ -1,3 +1,12 @@
+2002-07-02  Ziemowit Laski  <zlaski@apple.com>
+
+       * c-parse.in (designator): Enable designated initializers if ObjC.
+       (objcmessageexpr): Remove references to objc_receiver_context.
+       * objc/objc-act.h (objc_receiver_context): Remove decl.
+       * objc/objc-act.c (objc_receiver_context): Remove.
+       (lookup_objc_ivar): Test objc_method_context instead of
+       objc_receiver_context.
+
 Tue Jul  2 18:45:45 2002  J"orn Rennecke <joern.rennecke@superh.com>
 
        * sh.c (print_operand, case 'N'): Allow zero vector.
index 2a58668e0aac4e634f7c38016075b1753805fb85..6ce9a2e9516b93fb58373a4f9b594b2c1abb4495 100644 (file)
@@ -29,7 +29,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    written by AT&T, but I have never seen it.  */
 
 ifobjc
-%expect 31 /* shift/reduce conflicts, and 1 reduce/reduce conflict.  */
+%expect 32 /* shift/reduce conflicts, and 1 reduce/reduce conflict.  */
 end ifobjc
 ifc
 %expect 10 /* shift/reduce conflicts, and no reduce/reduce conflicts.  */
@@ -1566,17 +1566,12 @@ designator_list:
 designator:
          '.' identifier
                { set_init_label ($2); }
-       /* These are for labeled elements.  The syntax for an array element
-          initializer conflicts with the syntax for an Objective-C message,
-          so don't include these productions in the Objective-C grammar.  */
-ifc
        | '[' expr_no_commas ELLIPSIS expr_no_commas ']'
                { set_init_index ($2, $4);
                  if (pedantic)
                    pedwarn ("ISO C forbids specifying range of elements to initialize"); }
        | '[' expr_no_commas ']'
                { set_init_index ($2, NULL_TREE); }
-end ifc
        ;
 \f
 nested_function:
@@ -3223,14 +3218,8 @@ receiver:
        ;
 
 objcmessageexpr:
-         '['
-               { objc_receiver_context = 1; }
-         receiver
-               { objc_receiver_context = 0; }
-         messageargs ']'
-               {
-                 $$ = build_tree_list ($3, $5);
-               }
+         '[' receiver messageargs ']'
+               { $$ = build_tree_list ($2, $3); }
        ;
 
 selectorarg:
index 3909e0ca16f89506b74aae6f009fb7a8db4354f6..c0db5993d5641d55076bcb1f4b8d2dfee0ebbf21 100644 (file)
@@ -341,8 +341,6 @@ static const char *default_constant_string_class_name;
 /* The OCTI_... enumeration itself is in objc/objc-act.h.  */
 tree objc_global_trees[OCTI_MAX];
 
-int objc_receiver_context;
-
 static void handle_impent                      PARAMS ((struct imp_entry *));
 
 struct imp_entry *imp_list = 0;
@@ -8311,8 +8309,8 @@ lookup_objc_ivar (id)
 {
   tree decl;
 
-  if (objc_receiver_context && !strcmp (IDENTIFIER_POINTER (id), "super"))
-    /* we have a message to super */
+  if (objc_method_context && !strcmp (IDENTIFIER_POINTER (id), "super"))
+    /* We have a message to super.  */
     return get_super_receiver ();
   else if (objc_method_context && (decl = is_ivar (objc_ivar_chain, id)))
     {
index 17e5bd58c4d2b558892094e78e06c042768fad26..13b3e63de1f6f1391a37c1be6655b4d7e04e3b8b 100644 (file)
@@ -64,8 +64,6 @@ void objc_declare_alias                               PARAMS ((tree, tree));
 void objc_declare_class                                PARAMS ((tree));
 void objc_declare_protocols                    PARAMS ((tree));
 
-extern int objc_receiver_context;
-
 /* the following routines are used to implement statically typed objects */
 
 int objc_comptypes                             PARAMS ((tree, tree, int));
index b25b0ef318df21fc6f961d0f6dbf71466545f22f..014eacbb637171ee7e87c5426d18bdda4dd2ce71 100644 (file)
@@ -1,3 +1,7 @@
+2002-07-02  Ziemowit Laski  <zlaski@apple.com>
+
+       * objc.dg/desig-init-1.m: New test.
+
 2002-07-02  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/6716
diff --git a/gcc/testsuite/objc.dg/desig-init-1.m b/gcc/testsuite/objc.dg/desig-init-1.m
new file mode 100644 (file)
index 0000000..72fe833
--- /dev/null
@@ -0,0 +1,40 @@
+/* Test Objective-C capability for handling GNU/C99 designated
+   initializers, and distinguishing them from message sends.  */
+/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
+/* { dg-options "-std=gnu99" } */
+/* { dg-do run } */
+
+#include <stdio.h>           
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+@interface Cls : Object
++ (int) meth1;
++ (int) meth2;
++ (void) doTests;
+@end
+
+@implementation Cls
++ (int) meth1 { return 45; }
++ (int) meth2 { return 21; }
++ (void) doTests {
+  int arr[6] = { 
+    0, 
+    [Cls meth1], 
+    [2 + 1] = 3, 
+    [2 * 2 ... 5] = [0 meth2], /* { dg-warning "invalid receiver type" } */ 
+    [2] [Cls meth2]
+  };
+
+  if (arr[0] != 0 || arr[1] != 45 || arr[2] != 21 || arr[3] != 3)
+    abort (); /* { dg-warning "implicit declaration" } */
+
+  printf ("%s\n", [super name]);
+  printf ("%d %d %d %d %d %d\n", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]);
+}
+@end
+
+int main(void) {
+  [Cls doTests];
+  return 0;
+}