Kaynağa Gözat

--- Merging r29497 through r29498 into '.':
C compiler/msgtxt.inc
U compiler/symtable.pas
U compiler/msg/errore.msg
C compiler/msgidx.inc
A tests/test/tobjc41.pp
A tests/test/thlp48.pp
A tests/test/uobjc41.pp

# revisions: 29497,29498

git-svn-id: branches/fixes_3_0@29690 -

Jonas Maebe 10 yıl önce
ebeveyn
işleme
c378d75787

+ 3 - 0
.gitattributes

@@ -11763,6 +11763,7 @@ tests/test/thlp44.pp svneol=native#text/pascal
 tests/test/thlp45.pp svneol=native#text/pascal
 tests/test/thlp46.pp svneol=native#text/pascal
 tests/test/thlp47.pp svneol=native#text/pascal
+tests/test/thlp48.pp svneol=native#text/plain
 tests/test/thlp5.pp svneol=native#text/pascal
 tests/test/thlp6.pp svneol=native#text/pascal
 tests/test/thlp7.pp svneol=native#text/pascal
@@ -11940,6 +11941,7 @@ tests/test/tobjc38.pp svneol=native#text/plain
 tests/test/tobjc39.pp svneol=native#text/plain
 tests/test/tobjc4.pp svneol=native#text/plain
 tests/test/tobjc40.pp svneol=native#text/plain
+tests/test/tobjc41.pp svneol=native#text/plain
 tests/test/tobjc4a.pp svneol=native#text/plain
 tests/test/tobjc5.pp svneol=native#text/plain
 tests/test/tobjc5a.pp svneol=native#text/plain
@@ -12622,6 +12624,7 @@ tests/test/uobjc35e.pp svneol=native#text/plain
 tests/test/uobjc35f.pp svneol=native#text/plain
 tests/test/uobjc35g.pp svneol=native#text/plain
 tests/test/uobjc39.pp svneol=native#text/plain
+tests/test/uobjc41.pp svneol=native#text/plain
 tests/test/uobjc7.pp svneol=native#text/plain
 tests/test/uobjcl1.pp svneol=native#text/plain
 tests/test/uprec6.pp svneol=native#text/plain

+ 6 - 1
compiler/msg/errore.msg

@@ -1969,7 +1969,7 @@ type_w_instance_abstract_class=04122_W_Creating an instance of abstract class "$
 #
 # Symtable
 #
-# 05087 is the last used one
+# 05095 is the last used one
 #
 % \section{Symbol handling}
 % This section lists all the messages that concern the handling of symbols.
@@ -2273,6 +2273,11 @@ sym_h_managed_function_result_uninitialized=05094_H_Function result variable of
 % before it is initialized (i.e. it appears in the left-hand side of an
 % assignment). Since the variable is managed, i. e. implicitly initialized by the compiler, this might be intended behaviour and
 % does not necessarily mean that the code is wrong.
+sym_w_duplicate_id=05095_W_Duplicate identifier "$1"
+% The identifier was already declared in an Objective-C category that's in the
+% same scope as the current identifier. This is a warning instead of an error,
+% because while this hides the identifier from the category, there are often
+% many unused categories in scope.
 % \end{description}
 #
 # Codegenerator

+ 3 - 2
compiler/msgidx.inc

@@ -634,6 +634,7 @@ const
   sym_h_uninitialized_managed_variable=05092;
   sym_w_managed_function_result_uninitialized=05093;
   sym_h_managed_function_result_uninitialized=05094;
+  sym_w_duplicate_id=05095;
   cg_e_parasize_too_big=06009;
   cg_e_file_must_call_by_reference=06012;
   cg_e_cant_use_far_pointer_there=06013;
@@ -1000,9 +1001,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 74490;
+  MsgTxtSize = 74524;
 
   MsgIdxMax : array[1..20] of longint=(
-    26,99,339,123,95,57,126,27,202,64,
+    26,99,339,123,96,57,126,27,202,64,
     58,20,1,1,1,1,1,1,1,1
   );

Dosya farkı çok büyük olduğundan ihmal edildi
+ 254 - 249
compiler/msgtxt.inc


+ 21 - 9
compiler/symtable.pas

@@ -229,7 +229,7 @@ interface
     function generate_objectpascal_helper_key(def:tdef):string;
     procedure incompatibletypes(def1,def2:tdef);
     procedure hidesym(sym:TSymEntry);
-    procedure duplicatesym(var hashedid:THashedIDString;dupsym,origsym:TSymEntry);
+    procedure duplicatesym(var hashedid: THashedIDString; dupsym, origsym:TSymEntry; warn: boolean);
     function handle_generic_dummysym(sym:TSymEntry;var symoptions:tsymoptions):boolean;
     function get_jumpbuf_size : longint;
 
@@ -630,7 +630,7 @@ implementation
       begin
         hsym:=tsym(FindWithHash(hashedid));
         if assigned(hsym) then
-          DuplicateSym(hashedid,sym,hsym);
+          DuplicateSym(hashedid,sym,hsym,false);
         result:=assigned(hsym);
       end;
 
@@ -1461,7 +1461,8 @@ implementation
 
     function tObjectSymtable.checkduplicate(var hashedid:THashedIDString;sym:TSymEntry):boolean;
       var
-         hsym : tsym;
+         hsym: tsym;
+         warn: boolean;
       begin
          result:=false;
          if not assigned(defowner) then
@@ -1492,7 +1493,15 @@ implementation
                   )
                  ) then
                 begin
-                  DuplicateSym(hashedid,sym,hsym);
+                  { only watn when a parameter/local variable in a method
+                    conflicts with a category method, because this can easily
+                    happen due to all possible categories being imported via
+                    CocoaAll }
+                  warn:=
+                    (is_objccategory(tdef(hsym.owner.defowner)) or
+                     is_classhelper(tdef(hsym.owner.defowner))) and
+                    (sym.typ in [paravarsym,localvarsym,fieldvarsym]);
+                  DuplicateSym(hashedid,sym,hsym,warn);
                   result:=true;
                 end;
            end
@@ -1571,7 +1580,7 @@ implementation
                    (vo_is_result in tabstractvarsym(hsym).varoptions)) then
               HideSym(hsym)
             else
-              DuplicateSym(hashedid,sym,hsym);
+              DuplicateSym(hashedid,sym,hsym,false);
             result:=true;
             exit;
           end;
@@ -1591,7 +1600,7 @@ implementation
                    (vo_is_result in tabstractvarsym(sym).varoptions)) then
               Hidesym(sym)
             else
-              DuplicateSym(hashedid,sym,hsym);
+              DuplicateSym(hashedid,sym,hsym,false);
             result:=true;
             exit;
           end;
@@ -1697,7 +1706,7 @@ implementation
                   tnamespacesym(sym).unitsym:=tsym(hsym);
               end
             else
-              DuplicateSym(hashedid,sym,hsym);
+              DuplicateSym(hashedid,sym,hsym,false);
             result:=true;
             exit;
           end;
@@ -2040,11 +2049,14 @@ implementation
       end;
 
 
-    procedure duplicatesym(var hashedid:THashedIDString;dupsym,origsym:TSymEntry);
+    procedure duplicatesym(var hashedid: THashedIDString; dupsym, origsym: TSymEntry; warn: boolean);
       var
         st : TSymtable;
       begin
-        Message1(sym_e_duplicate_id,tsym(origsym).realname);
+        if not warn then
+          Message1(sym_e_duplicate_id,tsym(origsym).realname)
+        else
+         Message1(sym_w_duplicate_id,tsym(origsym).realname);
         { Write hint where the original symbol was found }
         st:=finduniTSymtable(origsym.owner);
         with tsym(origsym).fileinfo do

+ 24 - 0
tests/test/thlp48.pp

@@ -0,0 +1,24 @@
+{ %fail }
+{ %opt=-vw -Sew }
+
+program thelper;
+
+{$mode objfpc}
+
+type
+  TTest = class;
+
+  TTestHelper = class helper for TTest
+    procedure Test;
+  end;
+
+  TTest = class
+    Test: LongInt;
+  end;
+
+procedure TTestHelper.Test;
+begin
+end;
+
+begin
+end.

+ 24 - 0
tests/test/tobjc41.pp

@@ -0,0 +1,24 @@
+{ %target=darwin }
+{ %fail }
+{ %opt=-Sew }
+
+{$mode objfpc}
+{$modeswitch objectivec2}
+
+uses
+  uobjc41;
+
+type
+	NSDictionaryUtilities = objccategory (NSSubject)
+           { the "key" paramter should give a warning because there's already a "key"
+             message in a category for NSObject }
+		function containsKey (key: NSString): boolean; message 'containsKey:';
+	end;
+
+function NSDictionaryUtilities.containsKey (key: NSString): boolean;
+begin
+  result:=false;
+end;
+
+begin
+end.

+ 23 - 0
tests/test/uobjc41.pp

@@ -0,0 +1,23 @@
+{$mode objfpc}
+{$modeswitch objectivec2}
+
+unit uobjc41;
+
+interface
+
+type
+  NSSubject = objcclass(NSObject)
+  end;
+
+  MyCategory = objccategory(NSObject)
+    procedure key; message 'key';
+  end;
+
+implementation
+
+procedure MyCategory.key;
+begin
+end;
+
+begin
+end.

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor