This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ObjC fixes for --enable-mapped-location


Ziemowit Laski <zlaski@apple.com> writes:

> On 23 Sep 2004, at 12.05, Zack Weinberg wrote:
>>
>> This patch makes it possible to bootstrap GCC with
>> --enable-mapped-location --enable-languages=c,c++,objc.  Or it did on
>> Friday.  I'm retesting, but that'll take a bit.  There are nontrivial
>> numbers of testsuite failures, but one thing at a time.
>>
>> Since I'm not up to speed on the present state of the ObjC front end,
>> I would like this patch reviewed by an ObjC maintainer.  The
>> annotate_expr_locus -> SET_EXPR_LOCATION changes I consider to be
>> obviously correct; the others, not so much.
>
> Looks reasonable to me, provided that you squash all the regressions,
> of course.

I have now squashed all of the regressions which appear in a default
configuration (i.e. *without* --enable-mapped-location).  I would
prefer to leave the regressions in the --enable-mapped-location case
to separate patches.

Here is a revised patch which includes all of the revisions you asked
for.  I also kluged a test, proto-lossage-4.m, which was getting
excess errors on 64-bit targets -- it is not clear to me what that
test is playing at, sending messages to int, but the most expedient
fix was to make it long int instead (which is the same width as a
pointer on all supported targets).  I find "nonexistent" preferable to
"non-existent".

Bootstrapped amd64-linux.

zw

objc:
        * objc-act.c: Change annotate_with_locus to SET_EXPR_LOCATION
        throughout.
        (objc_init): Only set input_line to 0 #ifndef USE_MAPPED_LOCATION.
        (build_selector_translation_table): Use %J in diagnostic
        instead of diddling input_line.  Fix spelling.
testsuite:
        * objc.dg/proto-lossage-4.m: Use long instead of int to avoid
        extra diagnostics on targets with 64-bit pointers.
        * objc.dg/selector-1.m: Adjust dg-warning regexp.

===================================================================
Index: objc/objc-act.c
--- objc/objc-act.c	22 Sep 2004 01:13:06 -0000	1.246
+++ objc/objc-act.c	24 Sep 2004 15:41:15 -0000
@@ -534,10 +534,12 @@ objc_init (void)
 #endif
     return false;
 
+#ifndef USE_MAPPED_LOCATION
   /* Force the line number back to 0; check_newline will have
      raised it to 1, which will make the builtin functions appear
      not to be built in.  */
   input_line = 0;
+#endif
 
   /* If gen_declaration desired, open the output file.  */
   if (flag_gen_declaration)
@@ -2305,15 +2307,8 @@ build_selector_translation_table (void)
               }
           }
         if (!found)
-          {
-            /* Adjust line number for warning message.  */
-            int save_lineno = input_line;
-            if (flag_next_runtime && TREE_PURPOSE (chain))
-              input_line = DECL_SOURCE_LINE (TREE_PURPOSE (chain));
-            warning ("creating selector for non existant method %s",
-                     IDENTIFIER_POINTER (TREE_VALUE (chain)));
-            input_line = save_lineno;
-          }
+	  warning ("%Jcreating selector for nonexistent method %qE",
+		   TREE_PURPOSE (chain), TREE_VALUE (chain));
       }
 
       expr = build_selector (TREE_VALUE (chain));
@@ -3031,11 +3026,11 @@ next_sjlj_build_catch_list (void)
     {
       t = build (MODIFY_EXPR, void_type_node, cur_try_context->rethrow_decl,
 		 cur_try_context->caught_decl);
-      annotate_with_locus (t, cur_try_context->end_catch_locus);
+      SET_EXPR_LOCATION (t, cur_try_context->end_catch_locus);
       append_to_statement_list (t, last);
 
       t = next_sjlj_build_try_exit ();
-      annotate_with_locus (t, cur_try_context->end_catch_locus);
+      SET_EXPR_LOCATION (t, cur_try_context->end_catch_locus);
       append_to_statement_list (t, last);
     }
 
@@ -3096,18 +3091,18 @@ next_sjlj_build_try_catch_finally (void)
 
   /* Build the outermost varible binding level.  */
   bind = build (BIND_EXPR, void_type_node, rethrow_decl, NULL, NULL);
-  annotate_with_locus (bind, cur_try_context->try_locus);
+  SET_EXPR_LOCATION (bind, cur_try_context->try_locus);
   TREE_SIDE_EFFECTS (bind) = 1;
 
   /* Initialize rethrow_decl.  */
   t = build (MODIFY_EXPR, void_type_node, rethrow_decl,
 	     convert (objc_object_type, null_pointer_node));
-  annotate_with_locus (t, cur_try_context->try_locus);
+  SET_EXPR_LOCATION (t, cur_try_context->try_locus);
   append_to_statement_list (t, &BIND_EXPR_BODY (bind));
 
   /* Build the outermost TRY_FINALLY_EXPR.  */
   try_fin = build (TRY_FINALLY_EXPR, void_type_node, NULL, NULL);
-  annotate_with_locus (try_fin, cur_try_context->try_locus);
+  SET_EXPR_LOCATION (try_fin, cur_try_context->try_locus);
   TREE_SIDE_EFFECTS (try_fin) = 1;
   append_to_statement_list (try_fin, &BIND_EXPR_BODY (bind));
 
@@ -3127,11 +3122,11 @@ next_sjlj_build_try_catch_finally (void)
     }
   else
     catch_seq = next_sjlj_build_exc_extract (rethrow_decl);
-  annotate_with_locus (catch_seq, cur_try_context->end_try_locus);
+  SET_EXPR_LOCATION (catch_seq, cur_try_context->end_try_locus);
 
   /* Build the main register-and-try if statement.  */
   t = next_sjlj_build_enter_and_setjmp ();
-  annotate_with_locus (t, cur_try_context->try_locus);
+  SET_EXPR_LOCATION (t, cur_try_context->try_locus);
   COND_EXPR_THEN (t) = catch_seq;
   COND_EXPR_ELSE (t) = cur_try_context->try_body;
   TREE_OPERAND (try_fin, 0) = t;
@@ -3141,7 +3136,7 @@ next_sjlj_build_try_catch_finally (void)
   t = build_stmt (COND_EXPR,
 		  lang_hooks.truthvalue_conversion (rethrow_decl),
 		  NULL, t);
-  annotate_with_locus (t, cur_try_context->finally_locus);
+  SET_EXPR_LOCATION (t, cur_try_context->finally_locus);
   append_to_statement_list (t, &TREE_OPERAND (try_fin, 1));
 
   append_to_statement_list (cur_try_context->finally_body,
@@ -3152,7 +3147,7 @@ next_sjlj_build_try_catch_finally (void)
   t = build_stmt (COND_EXPR,
 		  lang_hooks.truthvalue_conversion (rethrow_decl),
 		  t, NULL);
-  annotate_with_locus (t, cur_try_context->end_finally_locus);
+  SET_EXPR_LOCATION (t, cur_try_context->end_finally_locus);
   append_to_statement_list (t, &TREE_OPERAND (try_fin, 1));
 
   return bind;
@@ -3293,12 +3288,12 @@ objc_finish_try_stmt (void)
       if (c->catch_list)
 	{
           stmt = build_stmt (TRY_CATCH_EXPR, stmt, c->catch_list);
-	  annotate_with_locus (stmt, cur_try_context->try_locus);
+	  SET_EXPR_LOCATION (stmt, cur_try_context->try_locus);
 	}
       if (c->finally_body)
 	{
 	  stmt = build_stmt (TRY_FINALLY_EXPR, stmt, c->finally_body);
-	  annotate_with_locus (stmt, cur_try_context->try_locus);
+	  SET_EXPR_LOCATION (stmt, cur_try_context->try_locus);
 	}
     }
   add_stmt (stmt);
@@ -3345,13 +3340,13 @@ objc_build_synchronized (location_t star
   mutex = save_expr (mutex);
   args = tree_cons (NULL, mutex, NULL);
   call = build_function_call (objc_sync_enter_decl, args);
-  annotate_with_locus (call, start_locus);
+  SET_EXPR_LOCATION (call, start_locus);
   add_stmt (call);
 
   /* Build the mutex unlock.  */
   args = tree_cons (NULL, mutex, NULL);
   call = build_function_call (objc_sync_exit_decl, args);
-  annotate_with_locus (call, input_location);
+  SET_EXPR_LOCATION (call, input_location);
 
   /* Put the that and the body in a TRY_FINALLY.  */
   objc_begin_try_stmt (start_locus, body);
===================================================================
Index: testsuite/objc.dg/proto-lossage-4.m
--- testsuite/objc.dg/proto-lossage-4.m	25 Aug 2004 20:38:53 -0000	1.2
+++ testsuite/objc.dg/proto-lossage-4.m	24 Sep 2004 15:41:17 -0000
@@ -7,25 +7,25 @@
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
 
 @protocol Proto
-- (int)someValue;
+- (long)someValue;
 @end
 
 @interface Obj
-- (int)anotherValue;
+- (long)anotherValue;
 @end
 
-int foo(void) {
-  int receiver = 2;
+long foo(void) {
+  long receiver = 2;
   Obj *objrcvr;
   Obj <Proto> *objrcvr2;
 
-  receiver += [receiver someValue]; /* { dg-warning "invalid receiver type .int( )?." } */
+  receiver += [receiver someValue]; /* { dg-warning "invalid receiver type .long int." } */
 /* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 22 } */
 /* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 22 } */
 /* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 22 } */
 /* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 22 } */
 
-  receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .int( )?." } */
+  receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .long int." } */
 /* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 28 } */
   
   receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
===================================================================
Index: testsuite/objc.dg/selector-1.m
--- testsuite/objc.dg/selector-1.m	8 Aug 2002 23:14:19 -0000	1.1
+++ testsuite/objc.dg/selector-1.m	24 Sep 2004 15:41:17 -0000
@@ -19,7 +19,7 @@ typedef struct objc_selector    *SEL;
 - (void) foo
 {
   SEL a,b,c;
-  a = @selector(b1ar); /* { dg-warning "creating selector for non existant method b1ar" } */
+  a = @selector(b1ar); /* { dg-warning "creating selector for nonexistent method .b1ar." } */
   b = @selector(bar);
 }
 @end


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]