Commit Graph

283 Commits

Author SHA1 Message Date
Sven/Sarah Barth
2372a06926 * fix #39740: consider a conversion of a procedure or procedure variable to a function reference as a bit more expensive than otherwise
+ added test
2022-05-31 22:50:14 +02:00
Sven/Sarah Barth
492754ecca * the check for nested procvars is now done during the conversion in capturer_add_procvar_or_proc so loosen the check in proc_to_funcref_equal_internal 2022-05-31 22:50:14 +02:00
Sven/Sarah Barth
4361e36ce0 * make proc_to_funcref_conv publicly available 2022-05-31 22:50:14 +02:00
Sven/Sarah Barth
5a680f0148 * fix #39745: the conversion from ordinals to pointer types in mode Delphi is not allowed for a void type (happens when using a typecast to convert a method without parameters to a function reference)
+ added test
2022-05-30 23:05:45 +02:00
Pierre Muller
bb39ec1610 Avoid invalid typecast to tabstractvarsym 2022-05-27 12:32:53 +00:00
Sven/Sarah Barth
7974f39522 * implement assignment of procedure and method variables and routines (global, instance and nested) to function references 2022-05-26 21:44:24 +02:00
Sven/Sarah Barth
76df7144ba * implement necessary conversion functionality for anonymous procdefs to function reference interfaces including capturing of variables 2022-05-26 21:44:23 +02:00
Sven/Sarah Barth
9b9ae2db1a * two function references are equal to each other as long as their signatures match 2022-05-26 21:44:23 +02:00
Sven/Sarah Barth
6fe9a15094 + add function to check whether a procdef can be converted to a function reference 2022-05-26 21:44:22 +02:00
Sven/Sarah Barth
47d7520b32 * consider invokables as related when they're equal 2022-05-26 21:43:39 +02:00
Sven/Sarah Barth
145b37425d + add function funcref_equal to check whether two function references are considered equal enough to be assignable 2022-05-26 21:43:39 +02:00
Sven/Sarah Barth
2be8f01efe * implement assignment of anonymous functions to procedure or method variables if they either capture nothing or (in case of method variables) at most the Self variable 2022-05-26 21:43:01 +02:00
Sven/Sarah Barth
17514ed5c0 * allow to ignore Self parameters; for this the parameter skipping needs to be repeated to correctly catch all cases 2022-05-26 21:43:01 +02:00
Sven/Sarah Barth
8e2478e632 * check whether an anonymous function can be assigned to a global, method or nested function variable 2022-05-26 21:43:01 +02:00
florian
6556d18bed * better fix for #39634 which avoids breaking existing code 2022-04-22 22:08:46 +02:00
Sven/Sarah Barth
094a353d87 + add ability to strictly compare defs with generic constraints (this is needed for declarations, while for normal code we're rather relaxed) 2022-02-18 17:53:35 +01:00
florian
aec18c2426 * weight currency->float conversions the same regardless if
the currency type is handled by the integer unit or the x87 fpu,
    resolves #38309

git-svn-id: trunk@48089 -
2021-01-05 22:39:16 +00:00
florian
1266afc0d0 * in equal_genfunc_paradefs take care of the fact that typesym might not be assigned for open array parameters, resolves #38012
git-svn-id: trunk@47253 -
2020-10-29 21:00:03 +00:00
svenbarth
2ff18e48a0 * fix for Mantis #36909: apply patch by Ryan Joseph so that array constructors can be used for static arrays as well.
+ added test

git-svn-id: trunk@46891 -
2020-09-18 15:00:15 +00:00
Jonas Maebe
23956e9f10 * prevent quadratic complexity in the size of the inheritance chain when
comparing objectdefs for equality

git-svn-id: trunk@46774 -
2020-09-05 12:25:13 +00:00
svenbarth
fa0c9adbf4 * extract checking whether two parameter defs of two procdefs are equal into a separate function
git-svn-id: trunk@45972 -
2020-07-31 15:55:31 +00:00
yury
72dc2145e9 * In Delphi mode throw a conversion error when trying to typecast a pointer to a procdef when they use different memory models.
git-svn-id: trunk@45856 -
2020-07-25 17:13:29 +00:00
svenbarth
52678562e3 * correctly handle selection between Single and Double overloads for Currency
+ added test

git-svn-id: trunk@45707 -
2020-06-27 22:33:36 +00:00
svenbarth
eaa2a2006c * fix for Mantis #37272: also allow the empty set for dynamic array parameters; Delphi probably started to allow that together with array constructors.
+ added tests

git-svn-id: trunk@45706 -
2020-06-27 22:33:31 +00:00
yury
2808873d1b * Reworked the optimization of unused $parentfp for nested routines.
- Do not remove the $parentfp parameter as was done in the previous optimization approach. Instead when $parentfp is unused to the following:
      - On the caller side: Omit passing the value for $parentfp for targets where tcgcallparanode.push_zero_sized_value_para=false (classic CPU targets). 
          Pass 0/nil as $parentfp for targets where tcgcallparanode.push_zero_sized_value_para=true;
      - On the callee side: Prevent allocation of registers/resources for $parentfp.
  - When possible keep $parentfp in a register.
  - Set the pio_nested_access flag in tprocinfo.set_needs_parentfp() to properly handle deep nesting levels;

git-svn-id: trunk@45436 -
2020-05-19 13:17:47 +00:00
yury
40504a6f9d * If a nested procedure does not access its parent's frame pointer, optimize it by removing the hidden $parentfp parameter.
* Improved the tisogoto1.pp test.

git-svn-id: trunk@45292 -
2020-05-06 14:43:49 +00:00
svenbarth
60345366f2 * fix for Mantis #35140: apply patch by Ryan Joseph together with some further changes by me to add support for constant parameters in generics
+ added tests

git-svn-id: trunk@45080 -
2020-04-25 22:12:35 +00:00
florian
fd20dc1086 * support unique copies of currencies which are handles by torddef, resolves #36013
git-svn-id: trunk@42837 -
2019-08-26 19:31:48 +00:00
Jonas Maebe
956aab3be0 * implement support for the Objective-C "related result type" convention
as described on
    http://releases.llvm.org/8.0.0/tools/clang/docs/LanguageExtensions.html#objective-c-features
    (rest of mantis #35994)

git-svn-id: trunk@42816 -
2019-08-25 15:23:53 +00:00
svenbarth
44bfa98a30 * fix for Mantis #35955: when the element of an array constructer requires an operator for conversion we don't let the caller of compare_defs_ext know that, instead we simply say that some conversion is required and let the typecheck handler deal with the element wise conversion
+ added test

git-svn-id: trunk@42700 -
2019-08-15 14:33:00 +00:00
Jonas Maebe
1da43f67d4 * (non-ancient) Delphi versions that accept explicit ordinal -> floating
point typecasts behave the same as FPC (convert the value) rather than
    as Turbo Pascal (reinterpret the bit pattern) (mantis #35886)

git-svn-id: trunk@42507 -
2019-07-28 11:14:54 +00:00
Jonas Maebe
c038e4c3f2 * relaxation of r42272: again only show warnings rather than errors for
out-of-range constants, because of the comments mentioned in #35753
    (except for enums, as apparently Delphi does the same)
  * added range check warnings about explicit type casts that throw away
    bits (e.g. byte($fff)), without giving warnings for most common cases
    (like cardinal(-1))
  * fixed masking/sign exting constant array indices (must be based on index
    range type size/signedness rather than on array size/"signedness")

git-svn-id: trunk@42275 -
2019-06-23 14:12:33 +00:00
Jonas Maebe
77658b925b * disable regular array -> dynamic array type coversion support unless
{$modeswitch arraytodynarray} is active (mantis #35576)
   o changed compiler to compile without this modeswitch
   o added the modeswitch to a test that depends on it

git-svn-id: trunk@42118 -
2019-05-25 12:31:32 +00:00
Jonas Maebe
281b3ad276 * fix case completeness and unreachable code warnings in compiler that would
be introduced by the next commit

git-svn-id: trunk@42046 -
2019-05-12 14:29:03 +00:00
florian
925531b99c * constrained generics are also compatible with formaldefs, resolves #34893
git-svn-id: trunk@40921 -
2019-01-19 21:23:36 +00:00
Jonas Maebe
50ab607676 + customint torddef type to create arbitraty bit-width integers
o use this to handle non-power-of-two-sized parameters for llvm
   o no general support in the parser/code generator, so don't expose

git-svn-id: trunk@40398 -
2018-11-29 20:57:08 +00:00
Jonas Maebe
9bd931e931 * make "formal const/var" parameters the least preferred conversion
(mantis #32179)
  - removed code to handle conversion to formaldef parameters that are not by
    reference (so the default conversion preference is kept)

git-svn-id: trunk@40012 -
2018-10-21 21:02:17 +00:00
Jonas Maebe
2c7c0d1144 * handle widechar constants directly in the scanner, instead of in the
overload selection (where you can't even know whether the string is
    a valid widechar constant) (mantis #33875)

git-svn-id: trunk@40009 -
2018-10-21 17:34:00 +00:00
Jonas Maebe
0b246f3dbd * converted Boolean8 to an internal type, and mapped Boolean to the
new internal pasbool1(type) (part of mantis #34411)
   o apply the _Bool x86-64 parameter passing rules only to pasbool1

git-svn-id: trunk@39949 -
2018-10-16 21:14:18 +00:00
florian
eea088c5f5 * allow nil to be assigned to generic types, resolves #34037
* niln is also a constant node

git-svn-id: trunk@39934 -
2018-10-14 07:38:13 +00:00
Jonas Maebe
1f9d518c57 * support for non-ASCII widechar constants (mantis #31605)
* also improved type checking for converting constant strings to integers
    in MacPas mode

git-svn-id: trunk@38730 -
2018-04-10 19:24:15 +00:00
nickysn
85ca504f4a * make near and far procedures/procvars incompatible with each other
git-svn-id: trunk@38645 -
2018-03-29 15:39:54 +00:00
svenbarth
5971e1327e * fix for Mantis #31756: have array constructors prefer open array parameters instead of dynamic array parameters for backwards compatibility
+ added test

git-svn-id: trunk@36175 -
2017-05-10 21:01:23 +00:00
svenbarth
bdef19fd79 * indeed allow the conversion of array constructors to dynamic arrays
git-svn-id: trunk@36100 -
2017-05-04 21:54:27 +00:00
svenbarth
df893b4a30 * implement a type conversion from an array constructor to a dynamic array
git-svn-id: trunk@36095 -
2017-05-04 21:34:38 +00:00
maciej-izak
ff28d5c85d * Fix usage of class operators in generics types. If we have generic type declaration/implementation then constraint in comparison to not specialized generic is not "exact" nor "incompatible". Mantis #30534.
git-svn-id: trunk@35740 -
2017-04-05 13:47:21 +00:00
svenbarth
5fa181b5d9 * second fix for Mantis #31033: also check for df_specialization instead of is_specialization for parameters to correctly handle nested types that aren't really true specializations themselves
+ added additional test

git-svn-id: trunk@35103 -
2016-12-10 19:47:09 +00:00
Jonas Maebe
94d7a7274b * compare floating point default parameter values bytewise instead of as
floating point values, so that NaNs can also be compared (mantis #30299)

git-svn-id: trunk@34597 -
2016-10-02 12:56:49 +00:00
svenbarth
0500c678e5 * fix for Mantis #30534: don't consider all types with generic constraints as equal, but at least ensure that they have the same basetype (Note: this still needs a bit more improvement)
+ added test

git-svn-id: trunk@34526 -
2016-09-16 13:24:28 +00:00
florian
a4d2f71d3d * better estimation of compatibility of array constructors with open arrays, resolves issue #29244
git-svn-id: trunk@32846 -
2016-01-04 23:10:45 +00:00