summaryrefslogtreecommitdiff
path: root/fpc-svn/38680_refined_htypechk.pas-2.patch
blob: e859cddd63c8143b1e02d45c61a593a5a98400e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
Index: compiler/htypechk.pas
===================================================================
--- compiler/htypechk.pas	(리비전 49131)
+++ compiler/htypechk.pas	(작업 사본)
@@ -2892,11 +2892,15 @@
         obj_to   : tobjectdef;
         def_from,
         def_to   : tdef;
+        tempn,
         currpt,
         pt       : tcallparanode;
+        eqtemp,
         eq,
         mineq    : tequaltype;
+        nconvtyp,
         convtype : tconverttype;
+        npd,
         pdtemp,
         pdoper   : tprocdef;
         releasecurrpt : boolean;
@@ -3001,7 +3005,10 @@
                   is_integer(def_to) and
                   is_in_limit(def_from,def_to) then
                  begin
-                   eq:=te_equal;
+                   if torddef(def_from).ordtype=torddef(def_to).ordtype then
+                     eq:=te_exact
+                     else
+                       eq:=te_equal;
                    hp^.ordinal_distance:=hp^.ordinal_distance+
                      abs(bestreal(torddef(def_from).low)-bestreal(torddef(def_to).low));
                    rth:=bestreal(torddef(def_to).high);
@@ -3023,7 +3030,10 @@
                   is_real_or_cextended(def_from) and
                   is_real_or_cextended(def_to) then
                  begin
-                   eq:=te_equal;
+                   if tfloatdef(def_from).floattype=tfloatdef(def_to).floattype then
+                     eq:=te_exact
+                     else
+                       eq:=te_equal;
                    if is_extended(def_to) then
                      rth:=4
                    else
@@ -3130,6 +3140,30 @@
                       para_allowed(eq,currpt,def_to);
                   end;
                end;
+              { to specialize pointer }
+              if (eq<te_exact) and
+                 is_pointer(def_from) and is_pointer(def_to) and
+                 (tstoreddef(tpointerdef(def_to).pointeddef).is_specialization) then
+                 begin
+                   eqtemp:=compare_defs_ext(tpointerdef(def_from).pointeddef,tpointerdef(def_to).pointeddef,nothingn,nconvtyp,npd,[cdo_equal_check]);
+                   if eqtemp<>te_exact then
+                       { void pointer }
+                       if currpt.left.nodetype=addrn then
+                       begin
+                         tempn:=tcallparanode(currpt.left);
+                         while assigned(tempn) do
+                         begin
+                           if tempn.nodetype in [loadn,derefn] then
+                           begin
+                             eqtemp:=compare_defs_ext(tempn.resultdef,tpointerdef(def_to).pointeddef,nothingn,nconvtyp,npd,[cdo_equal_check]);
+                             break;
+                           end;
+                           tempn:=tcallparanode(tempn.left);
+                         end;
+                       end;
+                   if eqtemp=te_exact then
+                     eq:=te_exact;
+                 end;
 
               { univ parameters match if the size matches (don't override the
                 comparison result if it was ok, since a match based on the
@@ -3145,7 +3179,6 @@
                 procvar is choosen. See tb0471 (PFV) }
               if (pt<>currpt) and (eq=te_exact) then
                 eq:=te_equal;
-
               { increase correct counter }
               case eq of
                 te_exact :
@@ -3291,53 +3324,53 @@
            res:=(bestpd^.coper_count-currpd^.coper_count);
            if (res=0) then
             begin
-             { less cl6 parameters? }
-             res:=(bestpd^.cl6_count-currpd^.cl6_count);
-             if (res=0) then
-              begin
-                { less cl5 parameters? }
-                res:=(bestpd^.cl5_count-currpd^.cl5_count);
-                if (res=0) then
-                 begin
-                  { less cl4 parameters? }
-                  res:=(bestpd^.cl4_count-currpd^.cl4_count);
+              { more exact parameters? }
+              res:=(currpd^.exact_count-bestpd^.exact_count);
+              if (res=0) then
+               begin
+               { less cl6 parameters? }
+               res:=(bestpd^.cl6_count-currpd^.cl6_count);
+               if (res=0) then
+                begin
+                  { less cl5 parameters? }
+                  res:=(bestpd^.cl5_count-currpd^.cl5_count);
                   if (res=0) then
                    begin
-                    { less cl3 parameters? }
-                    res:=(bestpd^.cl3_count-currpd^.cl3_count);
+                    { less cl4 parameters? }
+                    res:=(bestpd^.cl4_count-currpd^.cl4_count);
                     if (res=0) then
                      begin
-                       { less cl2 parameters? }
-                       res:=(bestpd^.cl2_count-currpd^.cl2_count);
-                       if (res=0) then
-                        begin
-                          { less cl1 parameters? }
-                          res:=(bestpd^.cl1_count-currpd^.cl1_count);
-                          if (res=0) then
-                           begin
-                             { more exact parameters? }
-                             res:=(currpd^.exact_count-bestpd^.exact_count);
-                             if (res=0) then
-                              begin
-                                { less equal parameters? }
-                                res:=(bestpd^.equal_count-currpd^.equal_count);
-                                if (res=0) then
-                                 begin
-                                   { smaller ordinal distance? }
-                                   if (currpd^.ordinal_distance<bestpd^.ordinal_distance) then
-                                    res:=1
-                                   else
-                                    if (currpd^.ordinal_distance>bestpd^.ordinal_distance) then
-                                     res:=-1
-                                   else
-                                    res:=0;
-                                 end;
-                              end;
-                           end;
-                        end;
+                      { less cl3 parameters? }
+                      res:=(bestpd^.cl3_count-currpd^.cl3_count);
+                      if (res=0) then
+                       begin
+                         { less cl2 parameters? }
+                         res:=(bestpd^.cl2_count-currpd^.cl2_count);
+                         if (res=0) then
+                          begin
+                            { less cl1 parameters? }
+                            res:=(bestpd^.cl1_count-currpd^.cl1_count);
+                            if (res=0) then
+                             begin
+                              { less equal parameters? }
+                              res:=(bestpd^.equal_count-currpd^.equal_count);
+                              if (res=0) then
+                               begin
+                                 { smaller ordinal distance? }
+                                 if (currpd^.ordinal_distance<bestpd^.ordinal_distance) then
+                                  res:=1
+                                 else
+                                  if (currpd^.ordinal_distance>bestpd^.ordinal_distance) then
+                                   res:=-1
+                                 else
+                                  res:=0;
+                               end;
+                             end;
+                          end;
+                       end;
                      end;
                    end;
-                 end;
+                end;
               end;
             end;
          end;
@@ -3608,7 +3641,7 @@
           cpoptions:=cpoptions+[cpo_rtlproc];
 
         compare_by_old_sortout_check := 0; // can't decide, bestpd probably wasn't sorted out in unpatched
-        if (compare_paras(pd^.data.paras,bestpd^.data.paras,cp_value_equal_const,cpoptions)>=te_equal) and
+        if (compare_paras(pd^.data.paras,bestpd^.data.paras,cp_value_equal_const,cpoptions)>te_equal) and
           (not(po_objc in bestpd^.data.procoptions) or (bestpd^.data.messageinf.str^=pd^.data.messageinf.str^)) then
           compare_by_old_sortout_check := 1; // bestpd was sorted out before patch
      end;
@@ -3643,7 +3676,6 @@
         end;
       end;
 
-
     function tcallcandidates.choose_best(var bestpd:tabstractprocdef; singlevariant: boolean):integer;
       var
         pd: tprocdef;