defcmp.pas 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Compare definitions and parameter lists
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit defcmp;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cclasses,
  23. globtype,globals,
  24. node,
  25. symconst,symtype,symdef;
  26. type
  27. { if acp is cp_all the var const or nothing are considered equal }
  28. tcompare_paras_type = ( cp_none, cp_value_equal_const, cp_all,cp_procvar);
  29. tcompare_paras_option = (cpo_allowdefaults,cpo_ignorehidden,cpo_allowconvert,cpo_comparedefaultvalue);
  30. tcompare_paras_options = set of tcompare_paras_option;
  31. tcompare_defs_option = (cdo_internal,cdo_explicit,cdo_check_operator,cdo_allow_variant);
  32. tcompare_defs_options = set of tcompare_defs_option;
  33. tconverttype = (
  34. tc_equal,
  35. tc_not_possible,
  36. tc_string_2_string,
  37. tc_char_2_string,
  38. tc_char_2_chararray,
  39. tc_pchar_2_string,
  40. tc_cchar_2_pchar,
  41. tc_cstring_2_pchar,
  42. tc_ansistring_2_pchar,
  43. tc_string_2_chararray,
  44. tc_chararray_2_string,
  45. tc_array_2_pointer,
  46. tc_pointer_2_array,
  47. tc_int_2_int,
  48. tc_int_2_bool,
  49. tc_bool_2_bool,
  50. tc_bool_2_int,
  51. tc_real_2_real,
  52. tc_int_2_real,
  53. tc_real_2_currency,
  54. tc_proc_2_procvar,
  55. tc_arrayconstructor_2_set,
  56. tc_load_smallset,
  57. tc_cord_2_pointer,
  58. tc_intf_2_string,
  59. tc_intf_2_guid,
  60. tc_class_2_intf,
  61. tc_char_2_char,
  62. tc_normal_2_smallset,
  63. tc_dynarray_2_openarray,
  64. tc_pwchar_2_string,
  65. tc_variant_2_dynarray,
  66. tc_dynarray_2_variant,
  67. tc_variant_2_enum,
  68. tc_enum_2_variant
  69. );
  70. function compare_defs_ext(def_from,def_to : tdef;
  71. fromtreetype : tnodetype;
  72. var doconv : tconverttype;
  73. var operatorpd : tprocdef;
  74. cdoptions:tcompare_defs_options):tequaltype;
  75. { Returns if the type def_from can be converted to def_to or if both types are equal }
  76. function compare_defs(def_from,def_to:tdef;fromtreetype:tnodetype):tequaltype;
  77. { Returns true, if def1 and def2 are semantically the same }
  78. function equal_defs(def_from,def_to:tdef):boolean;
  79. { Checks for type compatibility (subgroups of type)
  80. used for case statements... probably missing stuff
  81. to use on other types }
  82. function is_subequal(def1, def2: tdef): boolean;
  83. {# true, if two parameter lists are equal
  84. if acp is cp_none, all have to match exactly
  85. if acp is cp_value_equal_const call by value
  86. and call by const parameter are assumed as
  87. equal
  88. allowdefaults indicates if default value parameters
  89. are allowed (in this case, the search order will first
  90. search for a routine with default parameters, before
  91. searching for the same definition with no parameters)
  92. }
  93. function compare_paras(para1,para2 : tlist; acp : tcompare_paras_type; cpoptions: tcompare_paras_options):tequaltype;
  94. { True if a function can be assigned to a procvar }
  95. { changed first argument type to pabstractprocdef so that it can also be }
  96. { used to test compatibility between two pprocvardefs (JM) }
  97. function proc_to_procvar_equal(def1:tabstractprocdef;def2:tprocvardef;methoderr:boolean):tequaltype;
  98. implementation
  99. uses
  100. verbose,systems,
  101. symtable,symsym,
  102. defutil,symutil;
  103. function compare_defs_ext(def_from,def_to : tdef;
  104. fromtreetype : tnodetype;
  105. var doconv : tconverttype;
  106. var operatorpd : tprocdef;
  107. cdoptions:tcompare_defs_options):tequaltype;
  108. { Tbasetype:
  109. uvoid,
  110. u8bit,u16bit,u32bit,u64bit,
  111. s8bit,s16bit,s32bit,s64bit,
  112. bool8bit,bool16bit,bool32bit,
  113. uchar,uwidechar }
  114. type
  115. tbasedef=(bvoid,bchar,bint,bbool);
  116. const
  117. basedeftbl:array[tbasetype] of tbasedef =
  118. (bvoid,
  119. bint,bint,bint,bint,
  120. bint,bint,bint,bint,
  121. bbool,bbool,bbool,
  122. bchar,bchar,bint);
  123. basedefconvertsimplicit : array[tbasedef,tbasedef] of tconverttype =
  124. { void, char, int, bool }
  125. ((tc_not_possible,tc_not_possible,tc_not_possible,tc_not_possible),
  126. (tc_not_possible,tc_char_2_char,tc_not_possible,tc_not_possible),
  127. (tc_not_possible,tc_not_possible,tc_int_2_int,tc_not_possible),
  128. (tc_not_possible,tc_not_possible,tc_not_possible,tc_bool_2_bool));
  129. basedefconvertsexplicit : array[tbasedef,tbasedef] of tconverttype =
  130. { void, char, int, bool }
  131. ((tc_not_possible,tc_not_possible,tc_not_possible,tc_not_possible),
  132. (tc_not_possible,tc_char_2_char,tc_int_2_int,tc_int_2_bool),
  133. (tc_not_possible,tc_int_2_int,tc_int_2_int,tc_int_2_bool),
  134. (tc_not_possible,tc_bool_2_int,tc_bool_2_int,tc_bool_2_bool));
  135. var
  136. subeq,eq : tequaltype;
  137. hd1,hd2 : tdef;
  138. hct : tconverttype;
  139. hd3 : tobjectdef;
  140. hpd : tprocdef;
  141. begin
  142. { safety check }
  143. if not(assigned(def_from) and assigned(def_to)) then
  144. begin
  145. compare_defs_ext:=te_incompatible;
  146. exit;
  147. end;
  148. { same def? then we've an exact match }
  149. if def_from=def_to then
  150. begin
  151. compare_defs_ext:=te_exact;
  152. exit;
  153. end;
  154. { we walk the wanted (def_to) types and check then the def_from
  155. types if there is a conversion possible }
  156. eq:=te_incompatible;
  157. doconv:=tc_not_possible;
  158. case def_to.deftype of
  159. orddef :
  160. begin
  161. case def_from.deftype of
  162. orddef :
  163. begin
  164. if (torddef(def_from).typ=torddef(def_to).typ) then
  165. begin
  166. case torddef(def_from).typ of
  167. uchar,uwidechar,
  168. u8bit,u16bit,u32bit,u64bit,
  169. s8bit,s16bit,s32bit,s64bit:
  170. begin
  171. if (torddef(def_from).low=torddef(def_to).low) and
  172. (torddef(def_from).high=torddef(def_to).high) then
  173. eq:=te_equal
  174. else
  175. begin
  176. doconv:=tc_int_2_int;
  177. eq:=te_convert_l1;
  178. end;
  179. end;
  180. uvoid,
  181. bool8bit,bool16bit,bool32bit:
  182. eq:=te_equal;
  183. else
  184. internalerror(200210061);
  185. end;
  186. end
  187. else
  188. begin
  189. if cdo_explicit in cdoptions then
  190. doconv:=basedefconvertsexplicit[basedeftbl[torddef(def_from).typ],basedeftbl[torddef(def_to).typ]]
  191. else
  192. doconv:=basedefconvertsimplicit[basedeftbl[torddef(def_from).typ],basedeftbl[torddef(def_to).typ]];
  193. if (doconv=tc_not_possible) then
  194. eq:=te_incompatible
  195. else
  196. { "punish" bad type conversions :) (JM) }
  197. if (not is_in_limit(def_from,def_to)) and
  198. (def_from.size > def_to.size) then
  199. eq:=te_convert_l3
  200. else
  201. eq:=te_convert_l1;
  202. end;
  203. end;
  204. enumdef :
  205. begin
  206. { needed for char(enum) }
  207. if cdo_explicit in cdoptions then
  208. begin
  209. doconv:=tc_int_2_int;
  210. eq:=te_convert_l1;
  211. end;
  212. end;
  213. floatdef :
  214. begin
  215. if is_currency(def_to) then
  216. begin
  217. doconv:=tc_real_2_currency;
  218. eq:=te_convert_l2;
  219. end;
  220. end;
  221. classrefdef,
  222. procvardef,
  223. pointerdef :
  224. begin
  225. if cdo_explicit in cdoptions then
  226. begin
  227. eq:=te_convert_l1;
  228. if (fromtreetype=niln) then
  229. begin
  230. { will be handled by the constant folding }
  231. doconv:=tc_equal;
  232. end
  233. else
  234. doconv:=tc_int_2_int;
  235. end;
  236. end;
  237. end;
  238. end;
  239. stringdef :
  240. begin
  241. case def_from.deftype of
  242. stringdef :
  243. begin
  244. { Constant string }
  245. if (fromtreetype=stringconstn) then
  246. begin
  247. if (tstringdef(def_from).string_typ=tstringdef(def_to).string_typ) then
  248. eq:=te_equal
  249. else
  250. begin
  251. doconv:=tc_string_2_string;
  252. { Don't prefer conversions from widestring to a
  253. normal string as we can loose information }
  254. if tstringdef(def_from).string_typ=st_widestring then
  255. eq:=te_convert_l1
  256. else
  257. begin
  258. if tstringdef(def_to).string_typ=st_widestring then
  259. eq:=te_convert_l1
  260. else
  261. eq:=te_equal; { we can change the stringconst node }
  262. end;
  263. end;
  264. end
  265. else
  266. { Same string type, for shortstrings also the length must match }
  267. if (tstringdef(def_from).string_typ=tstringdef(def_to).string_typ) and
  268. ((tstringdef(def_from).string_typ<>st_shortstring) or
  269. (tstringdef(def_from).len=tstringdef(def_to).len)) then
  270. eq:=te_equal
  271. else
  272. begin
  273. doconv:=tc_string_2_string;
  274. { Prefer conversions to shortstring over other
  275. conversions. This is compatible with Delphi (PFV) }
  276. if tstringdef(def_to).string_typ=st_shortstring then
  277. eq:=te_convert_l2
  278. else
  279. eq:=te_convert_l3;
  280. end;
  281. end;
  282. orddef :
  283. begin
  284. { char to string}
  285. if is_char(def_from) or
  286. is_widechar(def_from) then
  287. begin
  288. doconv:=tc_char_2_string;
  289. eq:=te_convert_l1;
  290. end;
  291. end;
  292. arraydef :
  293. begin
  294. { array of char to string, the length check is done by the firstpass of this node }
  295. if is_chararray(def_from) or
  296. (is_char(tarraydef(def_from).elementtype.def) and
  297. is_open_array(def_from)) then
  298. begin
  299. doconv:=tc_chararray_2_string;
  300. if is_open_array(def_from) or
  301. (is_shortstring(def_to) and
  302. (def_from.size <= 255)) or
  303. (is_ansistring(def_to) and
  304. (def_from.size > 255)) then
  305. eq:=te_convert_l1
  306. else
  307. eq:=te_convert_l2;
  308. end;
  309. end;
  310. pointerdef :
  311. begin
  312. { pchar can be assigned to short/ansistrings,
  313. but not in tp7 compatible mode }
  314. if not(m_tp7 in aktmodeswitches) then
  315. begin
  316. if is_pchar(def_from) then
  317. begin
  318. doconv:=tc_pchar_2_string;
  319. { prefer ansistrings because pchars can overflow shortstrings, }
  320. { but only if ansistrings are the default (JM) }
  321. if (is_shortstring(def_to) and
  322. not(cs_ansistrings in aktlocalswitches)) or
  323. (is_ansistring(def_to) and
  324. (cs_ansistrings in aktlocalswitches)) then
  325. eq:=te_convert_l1
  326. else
  327. eq:=te_convert_l2;
  328. end
  329. else if is_pwidechar(def_from) then
  330. begin
  331. doconv:=tc_pwchar_2_string;
  332. { prefer ansistrings because pchars can overflow shortstrings, }
  333. { but only if ansistrings are the default (JM) }
  334. if is_widestring(def_to) then
  335. eq:=te_convert_l1
  336. else
  337. eq:=te_convert_l3;
  338. end;
  339. end;
  340. end;
  341. end;
  342. end;
  343. floatdef :
  344. begin
  345. case def_from.deftype of
  346. orddef :
  347. begin { ordinal to real }
  348. if is_integer(def_from) or
  349. (is_currency(def_from) and
  350. (s64currencytype.def.deftype = floatdef)) then
  351. begin
  352. doconv:=tc_int_2_real;
  353. eq:=te_convert_l1;
  354. end
  355. else if is_currency(def_from)
  356. { and (s64currencytype.def.deftype = orddef)) } then
  357. begin
  358. { prefer conversion to orddef in this case, unless }
  359. { the orddef < currency (then it will get convert l3, }
  360. { and conversion to float is favoured) }
  361. doconv:=tc_int_2_real;
  362. eq:=te_convert_l2;
  363. end;
  364. end;
  365. floatdef :
  366. begin
  367. if tfloatdef(def_from).typ=tfloatdef(def_to).typ then
  368. eq:=te_equal
  369. else
  370. begin
  371. if (fromtreetype=realconstn) or
  372. not((cdo_explicit in cdoptions) and
  373. (m_delphi in aktmodeswitches)) then
  374. begin
  375. doconv:=tc_real_2_real;
  376. { do we loose precision? }
  377. if def_to.size<def_from.size then
  378. eq:=te_convert_l2
  379. else
  380. eq:=te_convert_l1;
  381. end;
  382. end;
  383. end;
  384. end;
  385. end;
  386. enumdef :
  387. begin
  388. case def_from.deftype of
  389. enumdef :
  390. begin
  391. if cdo_explicit in cdoptions then
  392. begin
  393. eq:=te_convert_l1;
  394. doconv:=tc_int_2_int;
  395. end
  396. else
  397. begin
  398. hd1:=def_from;
  399. while assigned(tenumdef(hd1).basedef) do
  400. hd1:=tenumdef(hd1).basedef;
  401. hd2:=def_to;
  402. while assigned(tenumdef(hd2).basedef) do
  403. hd2:=tenumdef(hd2).basedef;
  404. if (hd1=hd2) then
  405. begin
  406. eq:=te_convert_l1;
  407. { because of packenum they can have different sizes! (JM) }
  408. doconv:=tc_int_2_int;
  409. end;
  410. end;
  411. end;
  412. orddef :
  413. begin
  414. if cdo_explicit in cdoptions then
  415. begin
  416. eq:=te_convert_l1;
  417. doconv:=tc_int_2_int;
  418. end;
  419. end;
  420. variantdef :
  421. begin
  422. eq:=te_convert_l1;
  423. doconv:=tc_variant_2_enum;
  424. end;
  425. end;
  426. end;
  427. arraydef :
  428. begin
  429. { open array is also compatible with a single element of its base type }
  430. if is_open_array(def_to) and
  431. equal_defs(def_from,tarraydef(def_to).elementtype.def) then
  432. begin
  433. doconv:=tc_equal;
  434. eq:=te_convert_l1;
  435. end
  436. else
  437. begin
  438. case def_from.deftype of
  439. arraydef :
  440. begin
  441. { to dynamic array }
  442. if is_dynamic_array(def_to) then
  443. begin
  444. { dynamic array -> dynamic array }
  445. if is_dynamic_array(def_from) and
  446. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  447. eq:=te_equal;
  448. end
  449. else
  450. { to open array }
  451. if is_open_array(def_to) then
  452. begin
  453. { array constructor -> open array }
  454. if is_array_constructor(def_from) then
  455. begin
  456. if is_void(tarraydef(def_from).elementtype.def) then
  457. begin
  458. doconv:=tc_equal;
  459. eq:=te_convert_l1;
  460. end
  461. else
  462. begin
  463. subeq:=compare_defs_ext(tarraydef(def_from).elementtype.def,
  464. tarraydef(def_to).elementtype.def,
  465. arrayconstructorn,hct,hpd,[cdo_check_operator]);
  466. if (subeq>=te_equal) then
  467. begin
  468. doconv:=tc_equal;
  469. eq:=te_convert_l1;
  470. end
  471. else
  472. if (subeq>te_incompatible) then
  473. begin
  474. doconv:=hct;
  475. eq:=te_convert_l2;
  476. end;
  477. end;
  478. end
  479. else
  480. { dynamic array -> open array }
  481. if is_dynamic_array(def_from) and
  482. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  483. begin
  484. doconv:=tc_dynarray_2_openarray;
  485. eq:=te_convert_l2;
  486. end
  487. else
  488. { array -> open array }
  489. if equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  490. eq:=te_equal;
  491. end
  492. else
  493. { to array of const }
  494. if is_array_of_const(def_to) then
  495. begin
  496. if is_array_of_const(def_from) or
  497. is_array_constructor(def_from) then
  498. begin
  499. eq:=te_equal;
  500. end
  501. else
  502. { array of tvarrec -> array of const }
  503. if equal_defs(tarraydef(def_to).elementtype.def,tarraydef(def_from).elementtype.def) then
  504. begin
  505. doconv:=tc_equal;
  506. eq:=te_convert_l1;
  507. end;
  508. end
  509. else
  510. { other arrays }
  511. begin
  512. { open array -> array }
  513. if is_open_array(def_from) and
  514. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  515. begin
  516. eq:=te_equal
  517. end
  518. else
  519. { array -> array }
  520. if not(m_tp7 in aktmodeswitches) and
  521. not(m_delphi in aktmodeswitches) and
  522. (tarraydef(def_from).lowrange=tarraydef(def_to).lowrange) and
  523. (tarraydef(def_from).highrange=tarraydef(def_to).highrange) and
  524. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) and
  525. equal_defs(tarraydef(def_from).rangetype.def,tarraydef(def_to).rangetype.def) then
  526. begin
  527. eq:=te_equal
  528. end;
  529. end;
  530. end;
  531. pointerdef :
  532. begin
  533. { nil and voidpointers are compatible with dyn. arrays }
  534. if is_dynamic_array(def_to) and
  535. ((fromtreetype=niln) or
  536. is_voidpointer(def_from)) then
  537. begin
  538. doconv:=tc_equal;
  539. eq:=te_convert_l1;
  540. end
  541. else
  542. if is_zero_based_array(def_to) and
  543. equal_defs(tpointerdef(def_from).pointertype.def,tarraydef(def_to).elementtype.def) then
  544. begin
  545. doconv:=tc_pointer_2_array;
  546. eq:=te_convert_l1;
  547. end;
  548. end;
  549. stringdef :
  550. begin
  551. { string to char array }
  552. if (not is_special_array(def_to)) and
  553. is_char(tarraydef(def_to).elementtype.def) then
  554. begin
  555. doconv:=tc_string_2_chararray;
  556. eq:=te_convert_l1;
  557. end;
  558. end;
  559. orddef:
  560. begin
  561. if is_chararray(def_to) and
  562. is_char(def_from) then
  563. begin
  564. doconv:=tc_char_2_chararray;
  565. eq:=te_convert_l2;
  566. end;
  567. end;
  568. recorddef :
  569. begin
  570. { tvarrec -> array of const }
  571. if is_array_of_const(def_to) and
  572. equal_defs(def_from,tarraydef(def_to).elementtype.def) then
  573. begin
  574. doconv:=tc_equal;
  575. eq:=te_convert_l1;
  576. end;
  577. end;
  578. variantdef :
  579. begin
  580. if is_dynamic_array(def_to) then
  581. begin
  582. doconv:=tc_variant_2_dynarray;
  583. eq:=te_convert_l1;
  584. end;
  585. end;
  586. end;
  587. end;
  588. end;
  589. variantdef :
  590. begin
  591. if (cdo_allow_variant in cdoptions) then
  592. begin
  593. case def_from.deftype of
  594. enumdef :
  595. begin
  596. doconv:=tc_enum_2_variant;
  597. eq:=te_convert_l1;
  598. end;
  599. arraydef :
  600. begin
  601. if is_dynamic_array(def_from) then
  602. begin
  603. doconv:=tc_dynarray_2_variant;
  604. eq:=te_convert_l1;
  605. end;
  606. end;
  607. end;
  608. end;
  609. end;
  610. pointerdef :
  611. begin
  612. case def_from.deftype of
  613. stringdef :
  614. begin
  615. { string constant (which can be part of array constructor)
  616. to zero terminated string constant }
  617. if (fromtreetype in [arrayconstructorn,stringconstn]) and
  618. (is_pchar(def_to) or is_pwidechar(def_to)) then
  619. begin
  620. doconv:=tc_cstring_2_pchar;
  621. eq:=te_convert_l1;
  622. end
  623. else
  624. if cdo_explicit in cdoptions then
  625. begin
  626. { pchar(ansistring) }
  627. if is_pchar(def_to) and
  628. is_ansistring(def_from) then
  629. begin
  630. doconv:=tc_ansistring_2_pchar;
  631. eq:=te_convert_l1;
  632. end
  633. else
  634. { pwidechar(ansistring) }
  635. if is_pwidechar(def_to) and
  636. is_widestring(def_from) then
  637. begin
  638. doconv:=tc_ansistring_2_pchar;
  639. eq:=te_convert_l1;
  640. end;
  641. end;
  642. end;
  643. orddef :
  644. begin
  645. { char constant to zero terminated string constant }
  646. if (fromtreetype=ordconstn) then
  647. begin
  648. if is_char(def_from) and
  649. is_pchar(def_to) then
  650. begin
  651. doconv:=tc_cchar_2_pchar;
  652. eq:=te_convert_l1;
  653. end
  654. else
  655. if (m_delphi in aktmodeswitches) and is_integer(def_from) then
  656. begin
  657. doconv:=tc_cord_2_pointer;
  658. eq:=te_convert_l1;
  659. end;
  660. end;
  661. { delphi compatible, allow explicit typecasts from
  662. ordinals to pointer.
  663. It is also used by the compiler internally for inc(pointer,ordinal) }
  664. if (eq=te_incompatible) and
  665. (
  666. (
  667. (m_delphi in aktmodeswitches) and
  668. (cdo_explicit in cdoptions)
  669. ) or
  670. (cdo_internal in cdoptions)
  671. ) then
  672. begin
  673. doconv:=tc_int_2_int;
  674. eq:=te_convert_l1;
  675. end;
  676. end;
  677. arraydef :
  678. begin
  679. { chararray to pointer }
  680. if is_zero_based_array(def_from) and
  681. equal_defs(tarraydef(def_from).elementtype.def,tpointerdef(def_to).pointertype.def) then
  682. begin
  683. doconv:=tc_array_2_pointer;
  684. eq:=te_convert_l1;
  685. end
  686. else
  687. { dynamic array to pointer, delphi only }
  688. if (m_delphi in aktmodeswitches) and
  689. is_dynamic_array(def_from) then
  690. begin
  691. eq:=te_equal;
  692. end;
  693. end;
  694. pointerdef :
  695. begin
  696. { check for far pointers }
  697. if (tpointerdef(def_from).is_far<>tpointerdef(def_to).is_far) then
  698. begin
  699. eq:=te_incompatible;
  700. end
  701. else
  702. { the types can be forward type, handle before normal type check !! }
  703. if assigned(def_to.typesym) and
  704. (tpointerdef(def_to).pointertype.def.deftype=forwarddef) then
  705. begin
  706. if (def_from.typesym=def_to.typesym) then
  707. eq:=te_equal
  708. end
  709. else
  710. { same types }
  711. if equal_defs(tpointerdef(def_from).pointertype.def,tpointerdef(def_to).pointertype.def) then
  712. begin
  713. eq:=te_equal
  714. end
  715. else
  716. { child class pointer can be assigned to anchestor pointers }
  717. if (
  718. (tpointerdef(def_from).pointertype.def.deftype=objectdef) and
  719. (tpointerdef(def_to).pointertype.def.deftype=objectdef) and
  720. tobjectdef(tpointerdef(def_from).pointertype.def).is_related(
  721. tobjectdef(tpointerdef(def_to).pointertype.def))
  722. ) then
  723. begin
  724. doconv:=tc_equal;
  725. eq:=te_convert_l1;
  726. end
  727. else
  728. { all pointers can be assigned to void-pointer }
  729. if is_void(tpointerdef(def_to).pointertype.def) then
  730. begin
  731. doconv:=tc_equal;
  732. { give pwidechar,pchar a penalty so it prefers
  733. conversion to ansistring }
  734. if is_pchar(def_from) or
  735. is_pwidechar(def_from) then
  736. eq:=te_convert_l2
  737. else
  738. eq:=te_convert_l1;
  739. end
  740. else
  741. { all pointers can be assigned from void-pointer }
  742. if is_void(tpointerdef(def_from).pointertype.def) then
  743. begin
  744. doconv:=tc_equal;
  745. { give pwidechar a penalty so it prefers
  746. conversion to pchar }
  747. if is_pwidechar(def_to) then
  748. eq:=te_convert_l2
  749. else
  750. eq:=te_convert_l1;
  751. end;
  752. end;
  753. procvardef :
  754. begin
  755. { procedure variable can be assigned to an void pointer }
  756. { Not anymore. Use the @ operator now.}
  757. if not(m_tp_procvar in aktmodeswitches) and
  758. { method pointers can't be assigned to void pointers
  759. not(tprocvardef(def_from).is_methodpointer) and }
  760. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  761. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  762. begin
  763. doconv:=tc_equal;
  764. eq:=te_convert_l1;
  765. end;
  766. end;
  767. classrefdef,
  768. objectdef :
  769. begin
  770. { class types and class reference type
  771. can be assigned to void pointers, but it is less
  772. preferred than assigning to a related objectdef }
  773. if (
  774. is_class_or_interface(def_from) or
  775. (def_from.deftype=classrefdef)
  776. ) and
  777. (tpointerdef(def_to).pointertype.def.deftype=orddef) and
  778. (torddef(tpointerdef(def_to).pointertype.def).typ=uvoid) then
  779. begin
  780. doconv:=tc_equal;
  781. eq:=te_convert_l2;
  782. end;
  783. end;
  784. end;
  785. end;
  786. setdef :
  787. begin
  788. case def_from.deftype of
  789. setdef :
  790. begin
  791. if assigned(tsetdef(def_from).elementtype.def) and
  792. assigned(tsetdef(def_to).elementtype.def) then
  793. begin
  794. { sets with the same element base type are equal }
  795. if is_subequal(tsetdef(def_from).elementtype.def,tsetdef(def_to).elementtype.def) then
  796. eq:=te_equal;
  797. end
  798. else
  799. { empty set is compatible with everything }
  800. eq:=te_equal;
  801. end;
  802. arraydef :
  803. begin
  804. { automatic arrayconstructor -> set conversion }
  805. if is_array_constructor(def_from) then
  806. begin
  807. doconv:=tc_arrayconstructor_2_set;
  808. eq:=te_convert_l1;
  809. end;
  810. end;
  811. end;
  812. end;
  813. procvardef :
  814. begin
  815. case def_from.deftype of
  816. procdef :
  817. begin
  818. { proc -> procvar }
  819. if (m_tp_procvar in aktmodeswitches) then
  820. begin
  821. subeq:=proc_to_procvar_equal(tprocdef(def_from),tprocvardef(def_to),true);
  822. if subeq>te_incompatible then
  823. begin
  824. doconv:=tc_proc_2_procvar;
  825. eq:=te_convert_l1;
  826. end;
  827. end;
  828. end;
  829. procvardef :
  830. begin
  831. { procvar -> procvar }
  832. eq:=proc_to_procvar_equal(tprocvardef(def_from),tprocvardef(def_to),false);
  833. end;
  834. pointerdef :
  835. begin
  836. { nil is compatible with procvars }
  837. if (fromtreetype=niln) then
  838. begin
  839. doconv:=tc_equal;
  840. eq:=te_convert_l1;
  841. end
  842. else
  843. { for example delphi allows the assignement from pointers }
  844. { to procedure variables }
  845. if (m_pointer_2_procedure in aktmodeswitches) and
  846. (tpointerdef(def_from).pointertype.def.deftype=orddef) and
  847. (torddef(tpointerdef(def_from).pointertype.def).typ=uvoid) then
  848. begin
  849. doconv:=tc_equal;
  850. eq:=te_convert_l1;
  851. end;
  852. end;
  853. end;
  854. end;
  855. objectdef :
  856. begin
  857. { object pascal objects }
  858. if (def_from.deftype=objectdef) and
  859. (tobjectdef(def_from).is_related(tobjectdef(def_to))) then
  860. begin
  861. doconv:=tc_equal;
  862. eq:=te_convert_l1;
  863. end
  864. else
  865. { Class/interface specific }
  866. if is_class_or_interface(def_to) then
  867. begin
  868. { void pointer also for delphi mode }
  869. if (m_delphi in aktmodeswitches) and
  870. is_voidpointer(def_from) then
  871. begin
  872. doconv:=tc_equal;
  873. { prefer pointer-pointer assignments }
  874. eq:=te_convert_l2;
  875. end
  876. else
  877. { nil is compatible with class instances and interfaces }
  878. if (fromtreetype=niln) then
  879. begin
  880. doconv:=tc_equal;
  881. eq:=te_convert_l1;
  882. end
  883. { classes can be assigned to interfaces }
  884. else if is_interface(def_to) and
  885. is_class(def_from) and
  886. assigned(tobjectdef(def_from).implementedinterfaces) then
  887. begin
  888. { we've to search in parent classes as well }
  889. hd3:=tobjectdef(def_from);
  890. while assigned(hd3) do
  891. begin
  892. if hd3.implementedinterfaces.searchintf(def_to)<>-1 then
  893. begin
  894. doconv:=tc_class_2_intf;
  895. eq:=te_convert_l1;
  896. break;
  897. end;
  898. hd3:=hd3.childof;
  899. end;
  900. end
  901. { Interface 2 GUID handling }
  902. else if (def_to=tdef(rec_tguid)) and
  903. (fromtreetype=typen) and
  904. is_interface(def_from) and
  905. assigned(tobjectdef(def_from).iidguid) then
  906. begin
  907. eq:=te_convert_l1;
  908. doconv:=tc_equal;
  909. end;
  910. end;
  911. end;
  912. classrefdef :
  913. begin
  914. { similar to pointerdef wrt forwards }
  915. if assigned(def_to.typesym) and
  916. (tclassrefdef(def_to).pointertype.def.deftype=forwarddef) then
  917. begin
  918. if (def_from.typesym=def_to.typesym) then
  919. eq:=te_equal;
  920. end
  921. else
  922. { class reference types }
  923. if (def_from.deftype=classrefdef) then
  924. begin
  925. if equal_defs(tclassrefdef(def_from).pointertype.def,tclassrefdef(def_to).pointertype.def) then
  926. begin
  927. eq:=te_equal;
  928. end
  929. else
  930. begin
  931. doconv:=tc_equal;
  932. if (cdo_explicit in cdoptions) or
  933. tobjectdef(tclassrefdef(def_from).pointertype.def).is_related(
  934. tobjectdef(tclassrefdef(def_to).pointertype.def)) then
  935. eq:=te_convert_l1;
  936. end;
  937. end
  938. else
  939. { nil is compatible with class references }
  940. if (fromtreetype=niln) then
  941. begin
  942. doconv:=tc_equal;
  943. eq:=te_convert_l1;
  944. end;
  945. end;
  946. filedef :
  947. begin
  948. { typed files are all equal to the abstract file type
  949. name TYPEDFILE in system.pp in is_equal in types.pas
  950. the problem is that it sholud be also compatible to FILE
  951. but this would leed to a problem for ASSIGN RESET and REWRITE
  952. when trying to find the good overloaded function !!
  953. so all file function are doubled in system.pp
  954. this is not very beautiful !!}
  955. if (def_from.deftype=filedef) then
  956. begin
  957. if (tfiledef(def_from).filetyp=tfiledef(def_to).filetyp) then
  958. begin
  959. if
  960. (
  961. (tfiledef(def_from).typedfiletype.def=nil) and
  962. (tfiledef(def_to).typedfiletype.def=nil)
  963. ) or
  964. (
  965. (tfiledef(def_from).typedfiletype.def<>nil) and
  966. (tfiledef(def_to).typedfiletype.def<>nil) and
  967. equal_defs(tfiledef(def_from).typedfiletype.def,tfiledef(def_to).typedfiletype.def)
  968. ) or
  969. (
  970. (tfiledef(def_from).filetyp = ft_typed) and
  971. (tfiledef(def_to).filetyp = ft_typed) and
  972. (
  973. (tfiledef(def_from).typedfiletype.def = tdef(voidtype.def)) or
  974. (tfiledef(def_to).typedfiletype.def = tdef(voidtype.def))
  975. )
  976. ) then
  977. begin
  978. eq:=te_equal;
  979. end;
  980. end
  981. else
  982. if ((tfiledef(def_from).filetyp = ft_untyped) and
  983. (tfiledef(def_to).filetyp = ft_typed)) or
  984. ((tfiledef(def_from).filetyp = ft_typed) and
  985. (tfiledef(def_to).filetyp = ft_untyped)) then
  986. begin
  987. doconv:=tc_equal;
  988. eq:=te_convert_l1;
  989. end;
  990. end;
  991. end;
  992. recorddef :
  993. begin
  994. { interface -> guid }
  995. if is_interface(def_from) and
  996. (def_to=rec_tguid) then
  997. begin
  998. doconv:=tc_intf_2_guid;
  999. eq:=te_convert_l1;
  1000. end;
  1001. end;
  1002. formaldef :
  1003. begin
  1004. doconv:=tc_equal;
  1005. if (def_from.deftype=formaldef) then
  1006. eq:=te_equal
  1007. else
  1008. { Just about everything can be converted to a formaldef...}
  1009. if not (def_from.deftype in [abstractdef,errordef]) then
  1010. eq:=te_convert_l1;
  1011. end;
  1012. end;
  1013. { if we didn't find an appropriate type conversion yet
  1014. then we search also the := operator }
  1015. if (eq=te_incompatible) and
  1016. (
  1017. { Check for variants? }
  1018. (
  1019. (cdo_allow_variant in cdoptions) and
  1020. ((def_from.deftype=variantdef) or (def_to.deftype=variantdef))
  1021. ) or
  1022. { Check for operators? }
  1023. (
  1024. (cdo_check_operator in cdoptions) and
  1025. ((def_from.deftype in [objectdef,recorddef,arraydef,stringdef,variantdef]) or
  1026. (def_to.deftype in [objectdef,recorddef,arraydef,stringdef,variantdef]))
  1027. )
  1028. ) then
  1029. begin
  1030. operatorpd:=search_assignment_operator(def_from,def_to);
  1031. if assigned(operatorpd) then
  1032. eq:=te_convert_operator;
  1033. end;
  1034. { update convtype for te_equal when it is not yet set }
  1035. if (eq=te_equal) and
  1036. (doconv=tc_not_possible) then
  1037. doconv:=tc_equal;
  1038. compare_defs_ext:=eq;
  1039. end;
  1040. function equal_defs(def_from,def_to:tdef):boolean;
  1041. var
  1042. convtyp : tconverttype;
  1043. pd : tprocdef;
  1044. begin
  1045. { Compare defs with nothingn and no explicit typecasts and
  1046. searching for overloaded operators is not needed }
  1047. equal_defs:=(compare_defs_ext(def_from,def_to,nothingn,convtyp,pd,[])>=te_equal);
  1048. end;
  1049. function compare_defs(def_from,def_to:tdef;fromtreetype:tnodetype):tequaltype;
  1050. var
  1051. doconv : tconverttype;
  1052. pd : tprocdef;
  1053. begin
  1054. compare_defs:=compare_defs_ext(def_from,def_to,fromtreetype,doconv,pd,[cdo_check_operator,cdo_allow_variant]);
  1055. end;
  1056. function is_subequal(def1, def2: tdef): boolean;
  1057. var
  1058. basedef1,basedef2 : tenumdef;
  1059. Begin
  1060. is_subequal := false;
  1061. if assigned(def1) and assigned(def2) then
  1062. Begin
  1063. if (def1.deftype = orddef) and (def2.deftype = orddef) then
  1064. Begin
  1065. { see p.47 of Turbo Pascal 7.01 manual for the separation of types }
  1066. { range checking for case statements is done with testrange }
  1067. case torddef(def1).typ of
  1068. u8bit,u16bit,u32bit,u64bit,
  1069. s8bit,s16bit,s32bit,s64bit :
  1070. is_subequal:=(torddef(def2).typ in [s64bit,u64bit,s32bit,u32bit,u8bit,s8bit,s16bit,u16bit]);
  1071. bool8bit,bool16bit,bool32bit :
  1072. is_subequal:=(torddef(def2).typ in [bool8bit,bool16bit,bool32bit]);
  1073. uchar :
  1074. is_subequal:=(torddef(def2).typ=uchar);
  1075. uwidechar :
  1076. is_subequal:=(torddef(def2).typ=uwidechar);
  1077. end;
  1078. end
  1079. else
  1080. Begin
  1081. { Check if both basedefs are equal }
  1082. if (def1.deftype=enumdef) and (def2.deftype=enumdef) then
  1083. Begin
  1084. { get both basedefs }
  1085. basedef1:=tenumdef(def1);
  1086. while assigned(basedef1.basedef) do
  1087. basedef1:=basedef1.basedef;
  1088. basedef2:=tenumdef(def2);
  1089. while assigned(basedef2.basedef) do
  1090. basedef2:=basedef2.basedef;
  1091. is_subequal:=(basedef1=basedef2);
  1092. end;
  1093. end;
  1094. end;
  1095. end;
  1096. function compare_paras(para1,para2 : tlist; acp : tcompare_paras_type; cpoptions: tcompare_paras_options):tequaltype;
  1097. var
  1098. currpara1,
  1099. currpara2 : tparavarsym;
  1100. eq,lowesteq : tequaltype;
  1101. hpd : tprocdef;
  1102. convtype : tconverttype;
  1103. cdoptions : tcompare_defs_options;
  1104. i1,i2 : byte;
  1105. begin
  1106. compare_paras:=te_incompatible;
  1107. cdoptions:=[cdo_check_operator,cdo_allow_variant];
  1108. { we need to parse the list from left-right so the
  1109. not-default parameters are checked first }
  1110. lowesteq:=high(tequaltype);
  1111. i1:=0;
  1112. i2:=0;
  1113. if cpo_ignorehidden in cpoptions then
  1114. begin
  1115. while (i1<para1.count) and
  1116. (vo_is_hidden_para in tparavarsym(para1[i1]).varoptions) do
  1117. inc(i1);
  1118. while (i2<para2.count) and
  1119. (vo_is_hidden_para in tparavarsym(para2[i2]).varoptions) do
  1120. inc(i2);
  1121. end;
  1122. while (i1<para1.count) and (i2<para2.count) do
  1123. begin
  1124. eq:=te_incompatible;
  1125. currpara1:=tparavarsym(para1[i1]);
  1126. currpara2:=tparavarsym(para2[i2]);
  1127. { Unique types must match exact }
  1128. if ((df_unique in currpara1.vartype.def.defoptions) or (df_unique in currpara2.vartype.def.defoptions)) and
  1129. (currpara1.vartype.def<>currpara2.vartype.def) then
  1130. exit;
  1131. { Handle hidden parameters separately, because self is
  1132. defined as voidpointer for methodpointers }
  1133. if (vo_is_hidden_para in currpara1.varoptions) or
  1134. (vo_is_hidden_para in currpara2.varoptions) then
  1135. begin
  1136. { both must be hidden }
  1137. if (vo_is_hidden_para in currpara1.varoptions)<>(vo_is_hidden_para in currpara2.varoptions) then
  1138. exit;
  1139. eq:=te_equal;
  1140. if not(vo_is_self in currpara1.varoptions) and
  1141. not(vo_is_self in currpara2.varoptions) then
  1142. begin
  1143. if (currpara1.varspez<>currpara2.varspez) then
  1144. exit;
  1145. eq:=compare_defs_ext(currpara1.vartype.def,currpara2.vartype.def,nothingn,
  1146. convtype,hpd,cdoptions);
  1147. end;
  1148. end
  1149. else
  1150. begin
  1151. case acp of
  1152. cp_value_equal_const :
  1153. begin
  1154. if (
  1155. (currpara1.varspez<>currpara2.varspez) and
  1156. ((currpara1.varspez in [vs_var,vs_out]) or
  1157. (currpara2.varspez in [vs_var,vs_out]))
  1158. ) then
  1159. exit;
  1160. eq:=compare_defs_ext(currpara1.vartype.def,currpara2.vartype.def,nothingn,
  1161. convtype,hpd,cdoptions);
  1162. end;
  1163. cp_all :
  1164. begin
  1165. if (currpara1.varspez<>currpara2.varspez) then
  1166. exit;
  1167. eq:=compare_defs_ext(currpara1.vartype.def,currpara2.vartype.def,nothingn,
  1168. convtype,hpd,cdoptions);
  1169. end;
  1170. cp_procvar :
  1171. begin
  1172. if (currpara1.varspez<>currpara2.varspez) then
  1173. exit;
  1174. eq:=compare_defs_ext(currpara1.vartype.def,currpara2.vartype.def,nothingn,
  1175. convtype,hpd,cdoptions);
  1176. { Parameters must be at least equal otherwise the are incompatible }
  1177. if (eq<te_equal) then
  1178. eq:=te_incompatible;
  1179. end;
  1180. else
  1181. eq:=compare_defs_ext(currpara1.vartype.def,currpara2.vartype.def,nothingn,
  1182. convtype,hpd,cdoptions);
  1183. end;
  1184. end;
  1185. { check type }
  1186. if eq=te_incompatible then
  1187. exit;
  1188. if eq<lowesteq then
  1189. lowesteq:=eq;
  1190. { also check default value if both have it declared }
  1191. if (cpo_comparedefaultvalue in cpoptions) and
  1192. assigned(currpara1.defaultconstsym) and
  1193. assigned(currpara2.defaultconstsym) then
  1194. begin
  1195. if not equal_constsym(tconstsym(currpara1.defaultconstsym),tconstsym(currpara2.defaultconstsym)) then
  1196. exit;
  1197. end;
  1198. inc(i1);
  1199. inc(i2);
  1200. if cpo_ignorehidden in cpoptions then
  1201. begin
  1202. while (i1<para1.count) and
  1203. (vo_is_hidden_para in tparavarsym(para1[i1]).varoptions) do
  1204. inc(i1);
  1205. while (i2<para2.count) and
  1206. (vo_is_hidden_para in tparavarsym(para2[i2]).varoptions) do
  1207. inc(i2);
  1208. end;
  1209. end;
  1210. { when both lists are empty then the parameters are equal. Also
  1211. when one list is empty and the other has a parameter with default
  1212. value assigned then the parameters are also equal }
  1213. if ((i1>=para1.count) and (i2>=para2.count)) or
  1214. ((cpo_allowdefaults in cpoptions) and
  1215. (((i1<para1.count) and assigned(tparavarsym(para1[i1]).defaultconstsym)) or
  1216. ((i2<para2.count) and assigned(tparavarsym(para2[i2]).defaultconstsym)))) then
  1217. compare_paras:=lowesteq;
  1218. end;
  1219. function proc_to_procvar_equal(def1:tabstractprocdef;def2:tprocvardef;methoderr:boolean):tequaltype;
  1220. var
  1221. eq : tequaltype;
  1222. po_comp : tprocoptions;
  1223. begin
  1224. proc_to_procvar_equal:=te_incompatible;
  1225. if not(assigned(def1)) or not(assigned(def2)) then
  1226. exit;
  1227. { check for method pointer }
  1228. if (def1.is_methodpointer xor def2.is_methodpointer) or
  1229. (def1.is_addressonly xor def2.is_addressonly) then
  1230. begin
  1231. if methoderr then
  1232. Message(type_e_no_method_and_procedure_not_compatible);
  1233. exit;
  1234. end;
  1235. { check return value and options, methodpointer is already checked }
  1236. po_comp:=[po_staticmethod,po_interrupt,
  1237. po_iocheck,po_varargs];
  1238. if (m_delphi in aktmodeswitches) then
  1239. exclude(po_comp,po_varargs);
  1240. if (def1.proccalloption=def2.proccalloption) and
  1241. ((po_comp * def1.procoptions)= (po_comp * def2.procoptions)) and
  1242. equal_defs(def1.rettype.def,def2.rettype.def) then
  1243. begin
  1244. { return equal type based on the parameters, but a proc->procvar
  1245. is never exact, so map an exact match of the parameters to
  1246. te_equal }
  1247. eq:=compare_paras(def1.paras,def2.paras,cp_procvar,[]);
  1248. if eq=te_exact then
  1249. eq:=te_equal;
  1250. proc_to_procvar_equal:=eq;
  1251. end;
  1252. end;
  1253. end.
  1254. {
  1255. $Log$
  1256. Revision 1.60 2004-11-26 22:33:54 peter
  1257. * don't allow pointer(ordinal) typecast in fpc mode, only allow it
  1258. for delphi and for internal use
  1259. Revision 1.59 2004/11/15 23:35:31 peter
  1260. * tparaitem removed, use tparavarsym instead
  1261. * parameter order is now calculated from paranr value in tparavarsym
  1262. Revision 1.58 2004/11/08 22:09:58 peter
  1263. * tvarsym splitted
  1264. Revision 1.57 2004/11/01 10:31:48 peter
  1265. * procvar arguments need to be at least equal
  1266. Revision 1.56 2004/11/01 08:02:26 peter
  1267. * remove previous patch
  1268. Revision 1.55 2004/10/31 22:05:25 peter
  1269. * only allow ordinal-pointer for same size
  1270. Revision 1.54 2004/10/31 21:45:02 peter
  1271. * generic tlocation
  1272. * move tlocation to cgutils
  1273. Revision 1.53 2004/09/21 15:52:35 peter
  1274. * prefer pchar-string over pchar-pointer
  1275. Revision 1.52 2004/09/16 16:32:44 peter
  1276. * dynarr-pointer is allowed under delphi
  1277. Revision 1.51 2004/06/20 08:55:29 florian
  1278. * logs truncated
  1279. Revision 1.50 2004/04/12 11:26:10 peter
  1280. * voidpointer can be converted to dynarray
  1281. Revision 1.49 2004/03/04 17:22:32 peter
  1282. * use defs_equal when comparing pointer types
  1283. Revision 1.48 2004/03/03 22:02:16 peter
  1284. * also compare calling convention in proc_to_procvar_equal
  1285. Revision 1.47 2004/02/24 16:12:39 peter
  1286. * operator overload chooses rewrite
  1287. * overload choosing is now generic and moved to htypechk
  1288. Revision 1.46 2004/02/15 12:18:22 peter
  1289. * allow real_2_real conversion for realconstn, fixes 2971
  1290. }