htypechk.pas 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839
  1. {
  2. $Id$
  3. Copyright (c) 1996-98 by Florian Klaempfl
  4. This unit exports some help routines for the type checking
  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 htypechk;
  19. interface
  20. uses
  21. tree,symtable;
  22. const
  23. { firstcallparan without varspez we don't count the ref }
  24. count_ref : boolean = true;
  25. get_para_resulttype : boolean = false;
  26. allow_array_constructor : boolean = false;
  27. { Conversion }
  28. function isconvertable(def_from,def_to : pdef;
  29. var doconv : tconverttype;fromtreetype : ttreetyp;
  30. explicit : boolean) : byte;
  31. { Register Allocation }
  32. procedure make_not_regable(p : ptree);
  33. procedure left_right_max(p : ptree);
  34. procedure calcregisters(p : ptree;r32,fpu,mmx : word);
  35. { subroutine handling }
  36. procedure test_protected_sym(sym : psym);
  37. procedure test_protected(p : ptree);
  38. function valid_for_formal_var(p : ptree) : boolean;
  39. function valid_for_formal_const(p : ptree) : boolean;
  40. function is_procsym_load(p:Ptree):boolean;
  41. function is_procsym_call(p:Ptree):boolean;
  42. function assignment_overloaded(from_def,to_def : pdef) : pprocdef;
  43. procedure test_local_to_procvar(from_def:pprocvardef;to_def:pdef);
  44. implementation
  45. uses
  46. globtype,systems,tokens,
  47. cobjects,verbose,globals,
  48. symconst,
  49. types,
  50. hcodegen;
  51. {****************************************************************************
  52. Convert
  53. ****************************************************************************}
  54. { Returns:
  55. 0 - Not convertable
  56. 1 - Convertable
  57. 2 - Convertable, but not first choice }
  58. function isconvertable(def_from,def_to : pdef;
  59. var doconv : tconverttype;fromtreetype : ttreetyp;
  60. explicit : boolean) : byte;
  61. { Tbasetype: uauto,uvoid,uchar,
  62. u8bit,u16bit,u32bit,
  63. s8bit,s16bit,s32,
  64. bool8bit,bool16bit,bool32bit,
  65. u64bit,s64bitint }
  66. type
  67. tbasedef=(bvoid,bchar,bint,bbool);
  68. const
  69. basedeftbl:array[tbasetype] of tbasedef =
  70. (bvoid,bvoid,bchar,
  71. bint,bint,bint,
  72. bint,bint,bint,
  73. bbool,bbool,bbool,bint,bint);
  74. basedefconverts : array[tbasedef,tbasedef] of tconverttype =
  75. ((tc_not_possible,tc_not_possible,tc_not_possible,tc_not_possible),
  76. (tc_not_possible,tc_equal,tc_not_possible,tc_not_possible),
  77. (tc_not_possible,tc_not_possible,tc_int_2_int,tc_int_2_bool),
  78. (tc_not_possible,tc_not_possible,tc_bool_2_int,tc_bool_2_bool));
  79. var
  80. b : byte;
  81. hd1,hd2 : pdef;
  82. hct : tconverttype;
  83. begin
  84. { safety check }
  85. if not(assigned(def_from) and assigned(def_to)) then
  86. begin
  87. isconvertable:=0;
  88. exit;
  89. end;
  90. b:=0;
  91. { we walk the wanted (def_to) types and check then the def_from
  92. types if there is a conversion possible }
  93. case def_to^.deftype of
  94. orddef :
  95. begin
  96. case def_from^.deftype of
  97. orddef :
  98. begin
  99. doconv:=basedefconverts[basedeftbl[porddef(def_from)^.typ],basedeftbl[porddef(def_to)^.typ]];
  100. b:=1;
  101. if (doconv=tc_not_possible) or
  102. ((doconv=tc_int_2_bool) and
  103. (not explicit) and
  104. (not is_boolean(def_from))) or
  105. ((doconv=tc_bool_2_int) and
  106. (not explicit) and
  107. (not is_boolean(def_to))) then
  108. b:=0;
  109. end;
  110. enumdef :
  111. begin
  112. { needed for char(enum) }
  113. if explicit then
  114. begin
  115. doconv:=tc_int_2_int;
  116. b:=1;
  117. end;
  118. end;
  119. end;
  120. end;
  121. stringdef :
  122. begin
  123. case def_from^.deftype of
  124. stringdef :
  125. begin
  126. doconv:=tc_string_2_string;
  127. b:=1;
  128. end;
  129. orddef :
  130. begin
  131. { char to string}
  132. if is_char(def_from) then
  133. begin
  134. doconv:=tc_char_2_string;
  135. b:=1;
  136. end;
  137. end;
  138. arraydef :
  139. begin
  140. { array of char to string, the length check is done by the firstpass of this node }
  141. if is_chararray(def_from) then
  142. begin
  143. doconv:=tc_chararray_2_string;
  144. if (not(cs_ansistrings in aktlocalswitches) and
  145. is_shortstring(def_to)) or
  146. ((cs_ansistrings in aktlocalswitches) and
  147. is_ansistring(def_to)) then
  148. b:=1
  149. else
  150. b:=2;
  151. end;
  152. end;
  153. pointerdef :
  154. begin
  155. { pchar can be assigned to short/ansistrings }
  156. if is_pchar(def_from) and not(m_tp in aktmodeswitches) then
  157. begin
  158. doconv:=tc_pchar_2_string;
  159. b:=1;
  160. end;
  161. end;
  162. end;
  163. end;
  164. floatdef :
  165. begin
  166. case def_from^.deftype of
  167. orddef :
  168. begin { ordinal to real }
  169. if is_integer(def_from) then
  170. begin
  171. if pfloatdef(def_to)^.typ=f32bit then
  172. doconv:=tc_int_2_fix
  173. else
  174. doconv:=tc_int_2_real;
  175. b:=1;
  176. end;
  177. end;
  178. floatdef :
  179. begin { 2 float types ? }
  180. if pfloatdef(def_from)^.typ=pfloatdef(def_to)^.typ then
  181. doconv:=tc_equal
  182. else
  183. begin
  184. if pfloatdef(def_from)^.typ=f32bit then
  185. doconv:=tc_fix_2_real
  186. else
  187. if pfloatdef(def_to)^.typ=f32bit then
  188. doconv:=tc_real_2_fix
  189. else
  190. doconv:=tc_real_2_real;
  191. end;
  192. b:=1;
  193. end;
  194. end;
  195. end;
  196. enumdef :
  197. begin
  198. if (def_from^.deftype=enumdef) then
  199. begin
  200. if assigned(penumdef(def_from)^.basedef) then
  201. hd1:=penumdef(def_from)^.basedef
  202. else
  203. hd1:=def_from;
  204. if assigned(penumdef(def_to)^.basedef) then
  205. hd2:=penumdef(def_to)^.basedef
  206. else
  207. hd2:=def_to;
  208. if (hd1=hd2) then
  209. b:=1;
  210. end;
  211. end;
  212. arraydef :
  213. begin
  214. { open array is also compatible with a single element of its base type }
  215. if is_open_array(def_to) and
  216. is_equal(parraydef(def_to)^.definition,def_from) then
  217. begin
  218. doconv:=tc_equal;
  219. b:=1;
  220. end
  221. else
  222. begin
  223. case def_from^.deftype of
  224. arraydef :
  225. begin
  226. { array constructor -> open array }
  227. if is_open_array(def_to) and
  228. is_array_constructor(def_from) then
  229. begin
  230. if is_equal(parraydef(def_to)^.definition,parraydef(def_from)^.definition) then
  231. begin
  232. doconv:=tc_equal;
  233. b:=1;
  234. end
  235. else
  236. if isconvertable(parraydef(def_to)^.definition,
  237. parraydef(def_from)^.definition,hct,nothingn,false)<>0 then
  238. begin
  239. doconv:=hct;
  240. b:=2;
  241. end;
  242. end;
  243. end;
  244. pointerdef :
  245. begin
  246. if is_zero_based_array(def_to) and
  247. is_equal(ppointerdef(def_from)^.definition,parraydef(def_to)^.definition) then
  248. begin
  249. doconv:=tc_pointer_2_array;
  250. b:=1;
  251. end;
  252. end;
  253. stringdef :
  254. begin
  255. { string to array of char}
  256. if (not(is_special_array(def_to)) or is_open_array(def_to)) and
  257. is_equal(parraydef(def_to)^.definition,cchardef) then
  258. begin
  259. doconv:=tc_string_2_chararray;
  260. b:=1;
  261. end;
  262. end;
  263. end;
  264. end;
  265. end;
  266. pointerdef :
  267. begin
  268. case def_from^.deftype of
  269. stringdef :
  270. begin
  271. { string constant to zero terminated string constant }
  272. if (fromtreetype=stringconstn) and
  273. is_pchar(def_to) then
  274. begin
  275. doconv:=tc_cstring_2_pchar;
  276. b:=1;
  277. end;
  278. end;
  279. orddef :
  280. begin
  281. { char constant to zero terminated string constant }
  282. if (fromtreetype=ordconstn) and is_equal(def_from,cchardef) and
  283. is_pchar(def_to) then
  284. begin
  285. doconv:=tc_cchar_2_pchar;
  286. b:=1;
  287. end;
  288. end;
  289. arraydef :
  290. begin
  291. { chararray to pointer }
  292. if is_zero_based_array(def_from) and
  293. is_equal(parraydef(def_from)^.definition,ppointerdef(def_to)^.definition) then
  294. begin
  295. doconv:=tc_array_2_pointer;
  296. b:=1;
  297. end;
  298. end;
  299. pointerdef :
  300. begin
  301. { child class pointer can be assigned to anchestor pointers }
  302. if (
  303. (ppointerdef(def_from)^.definition^.deftype=objectdef) and
  304. (ppointerdef(def_to)^.definition^.deftype=objectdef) and
  305. pobjectdef(ppointerdef(def_from)^.definition)^.is_related(
  306. pobjectdef(ppointerdef(def_to)^.definition))
  307. ) or
  308. { all pointers can be assigned to void-pointer }
  309. is_equal(ppointerdef(def_to)^.definition,voiddef) or
  310. { in my opnion, is this not clean pascal }
  311. { well, but it's handy to use, it isn't ? (FK) }
  312. is_equal(ppointerdef(def_from)^.definition,voiddef) then
  313. begin
  314. doconv:=tc_equal;
  315. b:=1;
  316. end;
  317. end;
  318. procvardef :
  319. begin
  320. { procedure variable can be assigned to an void pointer }
  321. { Not anymore. Use the @ operator now.}
  322. if not(m_tp_procvar in aktmodeswitches) and
  323. (ppointerdef(def_to)^.definition^.deftype=orddef) and
  324. (porddef(ppointerdef(def_to)^.definition)^.typ=uvoid) then
  325. begin
  326. doconv:=tc_equal;
  327. b:=1;
  328. end;
  329. end;
  330. classrefdef,
  331. objectdef :
  332. begin
  333. { class types and class reference type
  334. can be assigned to void pointers }
  335. if (
  336. ((def_from^.deftype=objectdef) and pobjectdef(def_from)^.is_class) or
  337. (def_from^.deftype=classrefdef)
  338. ) and
  339. (ppointerdef(def_to)^.definition^.deftype=orddef) and
  340. (porddef(ppointerdef(def_to)^.definition)^.typ=uvoid) then
  341. begin
  342. doconv:=tc_equal;
  343. b:=1;
  344. end;
  345. end;
  346. end;
  347. end;
  348. setdef :
  349. begin
  350. { automatic arrayconstructor -> set conversion }
  351. if is_array_constructor(def_from) then
  352. begin
  353. doconv:=tc_arrayconstructor_2_set;
  354. b:=1;
  355. end;
  356. end;
  357. procvardef :
  358. begin
  359. { proc -> procvar }
  360. if (def_from^.deftype=procdef) then
  361. begin
  362. doconv:=tc_proc_2_procvar;
  363. if proc_to_procvar_equal(pprocdef(def_from),pprocvardef(def_to)) then
  364. b:=1;
  365. end
  366. else
  367. { for example delphi allows the assignement from pointers }
  368. { to procedure variables }
  369. if (m_pointer_2_procedure in aktmodeswitches) and
  370. (def_from^.deftype=pointerdef) and
  371. (ppointerdef(def_from)^.definition^.deftype=orddef) and
  372. (porddef(ppointerdef(def_from)^.definition)^.typ=uvoid) then
  373. begin
  374. doconv:=tc_equal;
  375. b:=1;
  376. end
  377. else
  378. { nil is compatible with procvars }
  379. if (fromtreetype=niln) then
  380. begin
  381. doconv:=tc_equal;
  382. b:=1;
  383. end;
  384. end;
  385. objectdef :
  386. begin
  387. { object pascal objects }
  388. if (def_from^.deftype=objectdef) {and
  389. pobjectdef(def_from)^.isclass and pobjectdef(def_to)^.isclass }then
  390. begin
  391. doconv:=tc_equal;
  392. if pobjectdef(def_from)^.is_related(pobjectdef(def_to)) then
  393. b:=1;
  394. end
  395. else
  396. { nil is compatible with class instances }
  397. if (fromtreetype=niln) and (pobjectdef(def_to)^.is_class) then
  398. begin
  399. doconv:=tc_equal;
  400. b:=1;
  401. end;
  402. end;
  403. classrefdef :
  404. begin
  405. { class reference types }
  406. if (def_from^.deftype=classrefdef) then
  407. begin
  408. doconv:=tc_equal;
  409. if pobjectdef(pclassrefdef(def_from)^.definition)^.is_related(
  410. pobjectdef(pclassrefdef(def_to)^.definition)) then
  411. b:=1;
  412. end
  413. else
  414. { nil is compatible with class references }
  415. if (fromtreetype=niln) then
  416. begin
  417. doconv:=tc_equal;
  418. b:=1;
  419. end;
  420. end;
  421. filedef :
  422. begin
  423. { typed files are all equal to the abstract file type
  424. name TYPEDFILE in system.pp in is_equal in types.pas
  425. the problem is that it sholud be also compatible to FILE
  426. but this would leed to a problem for ASSIGN RESET and REWRITE
  427. when trying to find the good overloaded function !!
  428. so all file function are doubled in system.pp
  429. this is not very beautiful !!}
  430. if (def_from^.deftype=filedef) and
  431. (
  432. (
  433. (pfiledef(def_from)^.filetype = ft_typed) and
  434. (pfiledef(def_to)^.filetype = ft_typed) and
  435. (
  436. (pfiledef(def_from)^.typed_as = pdef(voiddef)) or
  437. (pfiledef(def_to)^.typed_as = pdef(voiddef))
  438. )
  439. ) or
  440. (
  441. (
  442. (pfiledef(def_from)^.filetype = ft_untyped) and
  443. (pfiledef(def_to)^.filetype = ft_typed)
  444. ) or
  445. (
  446. (pfiledef(def_from)^.filetype = ft_typed) and
  447. (pfiledef(def_to)^.filetype = ft_untyped)
  448. )
  449. )
  450. ) then
  451. begin
  452. doconv:=tc_equal;
  453. b:=1;
  454. end
  455. end;
  456. else
  457. begin
  458. { assignment overwritten ?? }
  459. if assignment_overloaded(def_from,def_to)<>nil then
  460. b:=2;
  461. end;
  462. end;
  463. isconvertable:=b;
  464. end;
  465. {****************************************************************************
  466. Register Calculation
  467. ****************************************************************************}
  468. { marks an lvalue as "unregable" }
  469. procedure make_not_regable(p : ptree);
  470. begin
  471. case p^.treetype of
  472. typeconvn :
  473. make_not_regable(p^.left);
  474. loadn :
  475. if p^.symtableentry^.typ=varsym then
  476. pvarsym(p^.symtableentry)^.varoptions:=pvarsym(p^.symtableentry)^.varoptions-[vo_regable,vo_fpuregable];
  477. end;
  478. end;
  479. procedure left_right_max(p : ptree);
  480. begin
  481. if assigned(p^.left) then
  482. begin
  483. if assigned(p^.right) then
  484. begin
  485. p^.registers32:=max(p^.left^.registers32,p^.right^.registers32);
  486. p^.registersfpu:=max(p^.left^.registersfpu,p^.right^.registersfpu);
  487. {$ifdef SUPPORT_MMX}
  488. p^.registersmmx:=max(p^.left^.registersmmx,p^.right^.registersmmx);
  489. {$endif SUPPORT_MMX}
  490. end
  491. else
  492. begin
  493. p^.registers32:=p^.left^.registers32;
  494. p^.registersfpu:=p^.left^.registersfpu;
  495. {$ifdef SUPPORT_MMX}
  496. p^.registersmmx:=p^.left^.registersmmx;
  497. {$endif SUPPORT_MMX}
  498. end;
  499. end;
  500. end;
  501. { calculates the needed registers for a binary operator }
  502. procedure calcregisters(p : ptree;r32,fpu,mmx : word);
  503. begin
  504. left_right_max(p);
  505. { Only when the difference between the left and right registers < the
  506. wanted registers allocate the amount of registers }
  507. if assigned(p^.left) then
  508. begin
  509. if assigned(p^.right) then
  510. begin
  511. if (abs(p^.left^.registers32-p^.right^.registers32)<r32) then
  512. inc(p^.registers32,r32);
  513. if (abs(p^.left^.registersfpu-p^.right^.registersfpu)<fpu) then
  514. inc(p^.registersfpu,fpu);
  515. {$ifdef SUPPORT_MMX}
  516. if (abs(p^.left^.registersmmx-p^.right^.registersmmx)<mmx) then
  517. inc(p^.registersmmx,mmx);
  518. {$endif SUPPORT_MMX}
  519. end
  520. else
  521. begin
  522. if (p^.left^.registers32<r32) then
  523. inc(p^.registers32,r32);
  524. if (p^.left^.registersfpu<fpu) then
  525. inc(p^.registersfpu,fpu);
  526. {$ifdef SUPPORT_MMX}
  527. if (p^.left^.registersmmx<mmx) then
  528. inc(p^.registersmmx,mmx);
  529. {$endif SUPPORT_MMX}
  530. end;
  531. end;
  532. { error CGMessage, if more than 8 floating point }
  533. { registers are needed }
  534. if p^.registersfpu>8 then
  535. CGMessage(cg_e_too_complex_expr);
  536. end;
  537. {****************************************************************************
  538. Subroutine Handling
  539. ****************************************************************************}
  540. { protected field handling
  541. protected field can not appear in
  542. var parameters of function !!
  543. this can only be done after we have determined the
  544. overloaded function
  545. this is the reason why it is not in the parser, PM }
  546. procedure test_protected_sym(sym : psym);
  547. begin
  548. if (sp_protected in sym^.symoptions) and
  549. ((sym^.owner^.symtabletype=unitsymtable) or
  550. ((sym^.owner^.symtabletype=objectsymtable) and
  551. (pobjectdef(sym^.owner^.defowner)^.owner^.symtabletype=unitsymtable))
  552. ) then
  553. CGMessage(parser_e_cant_access_protected_member);
  554. end;
  555. procedure test_protected(p : ptree);
  556. begin
  557. case p^.treetype of
  558. loadn : test_protected_sym(p^.symtableentry);
  559. typeconvn : test_protected(p^.left);
  560. derefn : test_protected(p^.left);
  561. subscriptn : begin
  562. { test_protected(p^.left);
  563. Is a field of a protected var
  564. also protected ??? PM }
  565. test_protected_sym(p^.vs);
  566. end;
  567. end;
  568. end;
  569. function valid_for_formal_var(p : ptree) : boolean;
  570. var
  571. v : boolean;
  572. begin
  573. case p^.treetype of
  574. loadn : v:=(p^.symtableentry^.typ in [typedconstsym,varsym]);
  575. typeconvn : v:=valid_for_formal_var(p^.left);
  576. typen : v:=false;
  577. derefn,subscriptn,vecn,
  578. funcretn,selfn : v:=true;
  579. { procvars are callnodes first }
  580. calln : v:=assigned(p^.right) and not assigned(p^.left);
  581. { should this depend on mode ? }
  582. addrn : v:=true;
  583. { no other node accepted (PM) }
  584. else v:=false;
  585. end;
  586. valid_for_formal_var:=v;
  587. end;
  588. function valid_for_formal_const(p : ptree) : boolean;
  589. var
  590. v : boolean;
  591. begin
  592. { p must have been firstpass'd before }
  593. { accept about anything but not a statement ! }
  594. v:=true;
  595. if (p^.treetype in [calln,statementn]) then
  596. { if not assigned(p^.resulttype) or (p^.resulttype=pdef(voiddef)) then }
  597. v:=false;
  598. valid_for_formal_const:=v;
  599. end;
  600. function is_procsym_load(p:Ptree):boolean;
  601. begin
  602. is_procsym_load:=((p^.treetype=loadn) and (p^.symtableentry^.typ=procsym)) or
  603. ((p^.treetype=addrn) and (p^.left^.treetype=loadn)
  604. and (p^.left^.symtableentry^.typ=procsym)) ;
  605. end;
  606. { change a proc call to a procload for assignment to a procvar }
  607. { this can only happen for proc/function without arguments }
  608. function is_procsym_call(p:Ptree):boolean;
  609. begin
  610. is_procsym_call:=(p^.treetype=calln) and (p^.left=nil) and
  611. (((p^.symtableprocentry^.typ=procsym) and (p^.right=nil)) or
  612. ((p^.right<>nil) and (p^.right^.symtableprocentry^.typ=varsym)));
  613. end;
  614. function assignment_overloaded(from_def,to_def : pdef) : pprocdef;
  615. var
  616. passproc : pprocdef;
  617. convtyp : tconverttype;
  618. begin
  619. assignment_overloaded:=nil;
  620. if assigned(overloaded_operators[_assignment]) then
  621. passproc:=overloaded_operators[_assignment]^.definition
  622. else
  623. exit;
  624. while passproc<>nil do
  625. begin
  626. if is_equal(passproc^.retdef,to_def) and
  627. (is_equal(passproc^.para1^.data,from_def) or
  628. (isconvertable(from_def,passproc^.para1^.data,convtyp,ordconstn,false)=1)) then
  629. begin
  630. assignment_overloaded:=passproc;
  631. break;
  632. end;
  633. passproc:=passproc^.nextoverloaded;
  634. end;
  635. end;
  636. { local routines can't be assigned to procvars }
  637. procedure test_local_to_procvar(from_def:pprocvardef;to_def:pdef);
  638. begin
  639. if (from_def^.symtablelevel>1) and (to_def^.deftype=procvardef) then
  640. CGMessage(type_e_cannot_local_proc_to_procvar);
  641. end;
  642. end.
  643. {
  644. $Log$
  645. Revision 1.38 1999-08-17 13:26:07 peter
  646. * arrayconstructor -> arrayofconst fixed when arraycosntructor was not
  647. variant.
  648. Revision 1.37 1999/08/16 23:23:38 peter
  649. * arrayconstructor -> openarray type conversions for element types
  650. Revision 1.36 1999/08/06 12:49:36 jonas
  651. * vo_fpuregable is now also removed in make_not_regable
  652. Revision 1.35 1999/08/05 21:50:35 peter
  653. * removed warning
  654. Revision 1.34 1999/08/05 16:52:55 peter
  655. * V_Fatal=1, all other V_ are also increased
  656. * Check for local procedure when assigning procvar
  657. * fixed comment parsing because directives
  658. * oldtp mode directives better supported
  659. * added some messages to errore.msg
  660. Revision 1.33 1999/08/04 13:02:43 jonas
  661. * all tokens now start with an underscore
  662. * PowerPC compiles!!
  663. Revision 1.32 1999/08/03 22:02:53 peter
  664. * moved bitmask constants to sets
  665. * some other type/const renamings
  666. Revision 1.31 1999/07/16 10:04:32 peter
  667. * merged
  668. Revision 1.30 1999/06/28 16:02:30 peter
  669. * merged
  670. Revision 1.27.2.4 1999/07/16 09:52:18 peter
  671. * allow char(enum)
  672. Revision 1.27.2.3 1999/06/28 15:51:27 peter
  673. * tp7 fix
  674. Revision 1.27.2.2 1999/06/18 10:56:58 daniel
  675. - Enumerations no longer compatible with integer types
  676. Revision 1.27.2.1 1999/06/17 12:51:42 pierre
  677. * changed is_assignment_overloaded into
  678. function assignment_overloaded : pprocdef
  679. to allow overloading of assignment with only different result type
  680. Revision 1.27 1999/06/01 19:27:47 peter
  681. * better checks for procvar and methodpointer
  682. Revision 1.26 1999/05/20 14:58:26 peter
  683. * fixed arrayconstruct->set conversion which didn't work for enum sets
  684. Revision 1.25 1999/05/19 20:40:12 florian
  685. * fixed a couple of array related bugs:
  686. - var a : array[0..1] of char; p : pchar; p:=a+123; works now
  687. - open arrays with an odd size doesn't work: movsb wasn't generated
  688. - introduced some new array type helper routines (is_special_array) etc.
  689. - made the array type checking in isconvertable more strict, often
  690. open array can be used where is wasn't allowed etc...
  691. Revision 1.24 1999/05/06 10:10:02 peter
  692. * overloaded conversion has lower priority
  693. Revision 1.23 1999/04/26 09:30:47 peter
  694. * small tp7 fix
  695. * fix void pointer with formaldef
  696. Revision 1.22 1999/04/21 22:00:01 pierre
  697. + valid_for_formal_var and valid_for_formal_const added
  698. Revision 1.21 1999/04/21 16:31:40 pierre
  699. ra386att.pas : problem with commit -m !
  700. Revision 1.20 1999/04/15 08:56:27 peter
  701. * fixed bool-bool conversion
  702. Revision 1.19 1999/03/24 23:17:02 peter
  703. * fixed bugs 212,222,225,227,229,231,233
  704. Revision 1.18 1999/03/06 17:25:19 peter
  705. * moved comp<->real warning so it doesn't occure everytime that
  706. isconvertable is called with
  707. Revision 1.17 1999/03/02 18:24:20 peter
  708. * fixed overloading of array of char
  709. Revision 1.16 1999/01/27 13:53:27 pierre
  710. htypechk.pas
  711. Revision 1.15 1999/01/27 13:12:10 pierre
  712. * bool to int must be explicit
  713. Revision 1.14 1999/01/19 15:55:32 pierre
  714. * fix for boolean to comp conversion (now disabled)
  715. Revision 1.13 1998/12/15 17:11:37 peter
  716. * string:=pchar not allowed in tp mode
  717. Revision 1.12 1998/12/11 00:03:18 peter
  718. + globtype,tokens,version unit splitted from globals
  719. Revision 1.11 1998/12/10 09:47:21 florian
  720. + basic operations with int64/qord (compiler with -dint64)
  721. + rtti of enumerations extended: names are now written
  722. Revision 1.10 1998/11/29 12:40:23 peter
  723. * newcnv -> not oldcnv
  724. Revision 1.9 1998/11/26 13:10:42 peter
  725. * new int - int conversion -dNEWCNV
  726. * some function renamings
  727. Revision 1.8 1998/11/17 00:36:42 peter
  728. * more ansistring fixes
  729. Revision 1.7 1998/10/14 13:33:24 peter
  730. * fixed small typo
  731. Revision 1.6 1998/10/14 12:53:38 peter
  732. * fixed small tp7 things
  733. * boolean:=longbool and longbool fixed
  734. Revision 1.5 1998/10/12 09:49:58 florian
  735. + support of <procedure var type>:=<pointer> in delphi mode added
  736. Revision 1.4 1998/09/30 16:42:52 peter
  737. * fixed bool-bool cnv
  738. Revision 1.3 1998/09/24 23:49:05 peter
  739. + aktmodeswitches
  740. Revision 1.2 1998/09/24 09:02:14 peter
  741. * rewritten isconvertable to use case
  742. * array of .. and single variable are compatible
  743. Revision 1.1 1998/09/23 20:42:22 peter
  744. * splitted pass_1
  745. }