Commit Graph

469 Commits

Author SHA1 Message Date
Sven/Sarah Barth
d221f42a57 * ensure that the correct overload is picked for function reference parameters
+ added tests
2022-11-06 22:01:49 +01:00
florian
2396b36c21 * nil =/<> dyn. array is a valid expression, so isbinaryoperatoroverloadable needs to take care of it, resolves #39933 2022-10-03 10:26:09 +02:00
florian
9a760db573 * nicer error message 2022-10-02 20:47:07 +02:00
Sven/Sarah Barth
e21186cac0 * fix #39902: in case of mode ObjFPC function pointers passed to parameters need to be checked for the correct procdef as well
+ added adjusted/extended test
2022-09-16 16:20:42 +02:00
Jonas Maebe
e746cf96da Overload selection: call procvars if result is compatible with parameter
Previously we only autmatically called procvars without parameters in TP/Delphi
modes if their result type was equal to the parameter type to which they were
passed. Resolves #39748.
2022-09-16 11:21:05 +02:00
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
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
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
b1d9d34665 * only abort due to a missing overload directive if there indeed was any procdef found (due to implicit specializations there might be none), fixes compilation of tests webtbs/tw38310b and webtbs/tw38310c 2022-04-21 18:01:30 +02:00
Sven/Sarah Barth
90844c2027 * fix #35261: apply slightly adjusted changes by Ryan Joseph to implement support for implicit generic function specializations
The main adjustments were as follows:
  - fixing coding style and identation
  - fixing some typos
  - using a better name for the property in tcallcandidates which holds the symbols created for anonymous parameter values
2022-04-20 18:59:31 +02:00
pierre
a7de0b365b Avoid invalid typecast error when using -CR option
git-svn-id: trunk@48978 -
2021-03-15 13:25:59 +00:00
svenbarth
57d9884d96 * fix for Mantis #38310: ignore procsyms that have no procdefs for checking overloads, or more precisely to stop checking for overloads; these are generic dummy symbols
+ added (simplified) tests

git-svn-id: trunk@48088 -
2021-01-05 20:58:46 +00:00
svenbarth
3597696e98 * fix for Mantis #38145: allow overloading of assignment operators that return ShortStrings with a specific size
+ added tests

The following rules for using these operator overloads as *implicit* overloads apply (Delphi compatible):
  - if a found assignment operator returns a default ShortString then that is used
  - if only one assignment operator to a String[x] is found then that is used
  - otherwise the assignment is not possible
The explicit assignment checks for an exact match (and falls back for an implicit assignment). This is not entirely Delphi compatible as Delphi seems to favor the first found symbol in that case, but sometimes also not... :/

git-svn-id: trunk@47634 -
2020-11-29 15:47:52 +00:00
florian
dfaee4f04b * patch by Jan Bruns to solve an issue with the new overloading selection code, resolves #37969
git-svn-id: trunk@47211 -
2020-10-26 20:58:24 +00:00
florian
3b0168ae16 * (slightly) modified (formatting, warning) patch by Jan Bruns to speed up overloading search, resolves #36666
git-svn-id: trunk@47111 -
2020-10-14 20:08:10 +00:00
florian
a628c1c3dd * if an array constructor is passed to a formaldef parameter, it is passed as a set (if the conversion is possible), resolves #37796
git-svn-id: trunk@46973 -
2020-09-27 16:37:20 +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
svenbarth
de35356a4d * when checking for an existing operator overload for the assignment operator, check for the correct variant (explicit or not) matching the overload
+ added tests

git-svn-id: trunk@44746 -
2020-04-17 14:44:14 +00:00
florian
9bd7401ce9 * comment fixed
git-svn-id: trunk@43805 -
2019-12-28 18:18:41 +00:00
florian
00859420ab * correctly handle reading of class/object pointers in combination with @, resolves #26326
git-svn-id: trunk@43804 -
2019-12-28 17:59:23 +00:00
Jonas Maebe
1a9e246c29 * added is_normal_fieldvarsym() helper and use it
o fixes several places where there was a check whether something is a
     fieldvarsym, but not whether it's an instance rather than a class field

git-svn-id: trunk@43786 -
2019-12-24 22:12:44 +00:00
florian
2f374a37b7 * patch by Bart Broersma to allow to declare "LongInt = AnsiString" comparison
operator in non-macpas modes, resolves #29460

git-svn-id: trunk@43709 -
2019-12-22 22:06:26 +00:00
svenbarth
0a915e883e * keep track of static symbols that a global function references, as those must now be exported from a dynamic package as well if the function can potentially be inlined
git-svn-id: trunk@43544 -
2019-11-21 21:44:53 +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
svenbarth
5a5b47fa24 + add support for MultiHelpers modeswitch by Ryan Joseph for Mantis #35159
+ added tests

git-svn-id: trunk@42026 -
2019-05-10 14:04:45 +00:00
svenbarth
e6add40495 * fix for Mantis #35348: correctly handle symbols that aren't parameter types (e.g. default values)
+ added test

git-svn-id: trunk@41869 -
2019-04-14 20:47:47 +00:00
svenbarth
c147debda1 * ensure that the correct amount of parameters is used for an operator overload (this is essentially important for unary operators that were declared with two arguments)
git-svn-id: trunk@41868 -
2019-04-14 20:47:43 +00:00
svenbarth
307ff071e6 * allow any untyped parameter to be passed to a untyped constref parameter
+ added test

git-svn-id: trunk@41829 -
2019-04-04 19:31:55 +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
yury
4682ac269d * Further improvement for r40180:
An uninitialized function Result of a managed type needs special handling.
    When passing it as a var parameter a warning need to be emitted, since a user
    may expect Result to be empty (nil) by default as it happens with local vars
    of a managed type. But this is not true for Result and may lead to serious issues.

    The only exception is SetLength(Result, ?) for a string Result. A user always
    expects undefined contents of the string after calling SetLength(). In such
    case a hint need to be emitted.
+ Tests for this.

git-svn-id: trunk@40216 -
2018-11-04 15:37:52 +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
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
svenbarth
97acf24290 + add a new modeswitch ArrayOperators which is set by default in Delphi modes that enables the internal array operators (currently only "+")
git-svn-id: trunk@39259 -
2018-06-20 19:53:43 +00:00
svenbarth
9b45f58c0b + add flags that allow checking for overloads with isbinaryoverloaded() and isunaryoverloaded() without modifying the passed in node or even checking for normally non-overloadable operators
git-svn-id: trunk@39258 -
2018-06-20 19:53:34 +00:00
florian
21d785e41b * do not unroll loops if the counter variable is accessed outside the current scope
git-svn-id: trunk@39163 -
2018-06-03 15:12:48 +00:00
florian
0fd0e356e1 + new flag ra_different_scope: used if a node tree is marked as non-regable if a variable is accessed from a different scope
git-svn-id: trunk@38689 -
2018-04-04 21:39:47 +00:00
florian
c230f81719 + support for <dyn. array>+<dyn. array>, resolves #30463
git-svn-id: trunk@38406 -
2018-03-04 16:12:43 +00:00
svenbarth
236a9b0aa5 * rework the checks for a helper's extended def to be a class so that it can be more easily extended by other objecttypes
git-svn-id: trunk@37022 -
2017-08-21 20:48:02 +00:00
nickysn
efc5e339d0 * use an enum instead of integer constants to represent inline numbers
* compinnr.inc include file converted to a unit
* inline number field size stored in ppu increased from byte to longint
* inlines in the parse tree (when written with the -vp option) now printed with
  their enum name, instead of number

git-svn-id: trunk@36174 -
2017-05-10 14:41:43 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
svenbarth
1aa80f77cb - remove no longer needed global variable allow_array_constructor
git-svn-id: trunk@36103 -
2017-05-04 21:58:14 +00:00
yury
5405a4727a * Removed unused vars.
git-svn-id: trunk@35535 -
2017-03-07 08:56:07 +00:00
svenbarth
ece13bcc5a * fix for Mantis #31465: only consider non-static fields when checking whether a record may be used with Default()
+ added test (Note: the test fails due to missing = operator, but without the fix there was a stack overflow)

git-svn-id: trunk@35508 -
2017-03-03 17:03:46 +00:00
maciej-izak
168e59837a * New function token2managementoperator for conversion: ttoken to tmanagementoperator
git-svn-id: trunk@35441 -
2017-02-18 18:58:32 +00:00
Jonas Maebe
7911cc8437 - removed some dataconstn remenants
git-svn-id: trunk@35314 -
2017-01-16 21:27:20 +00:00
Jonas Maebe
d66e0d6450 - got rid of gotclass and gotdynarray in valid_for_assign(), as these were
only used in combination with subscriptn/vecn to determine whether the
    target is assignable (and we return true immediately if you subscript
    or index an implicit pointer type -- also for classrefdef now)
   o disallow assigning something to fields of records returned by functions
     (that would be assigned to a temp and get lost anyway)

git-svn-id: trunk@35313 -
2017-01-16 21:12:24 +00:00
Jonas Maebe
382bbc1201 - removed gotderef from valid_for_assign(), and return true at every place
where it used to be set to true (dereferencing a pointer always means
    that regardless of what the pointer was, the resut is assignable)
    (mantis #22979)
   o also removed gotpointer, since it was only used in combination with
     gotderef

git-svn-id: trunk@35308 -
2017-01-15 16:32:51 +00:00
Jonas Maebe
99a1847e2f * fixed comment typo
git-svn-id: trunk@35307 -
2017-01-15 16:32:47 +00:00
Jonas Maebe
18077d9530 * when determining the best candidates for overloaded method calls, apply
the scope penalty relative to the nearest symtable that contains one of
    the applicable overloads, rather than relative to the nearest symtable
    that simply contains a method with this name (based on patch by
    Maciej Izak, mantis #25607)

git-svn-id: trunk@35089 -
2016-12-09 13:39:42 +00:00
svenbarth
d9ea6aae4d * fix for Mantis #30761: always return the symbol found in the helper instead of doing this dependant on the presence of the overload attribute; for this the collection of all suitable overloads is done in tcallcandidates instead.
+ added test

git-svn-id: trunk@35024 -
2016-11-30 17:52:25 +00:00