Commit Graph

484 Commits

Author SHA1 Message Date
Rika Ichinose
8498eacdeb Remove unused cutils functions. 2024-11-04 22:05:03 +00:00
Rika Ichinose
7343a12908 Use “set of (op_unary, op_binary)” to check for supported operator overloads. 2024-11-03 14:52:26 +00:00
Rika Ichinose
7a963ac56a Align htypechk.pas:is_better_candidate to the left edge of the screen. 2024-11-02 18:53:30 +03:00
florian
b28681e91d * properly reject function calls as target of absolute, resolves #40977
* better error message on invalid expressions for absolute
2024-10-29 22:23:25 +01:00
Rika Ichinose
510a281c3f Use a set instead of boolean arguments to TCallCandidates. 2024-10-27 16:45:35 +00:00
Rika Ichinose
326776c7fa Turn TCallCandidates into an object, make it create FIgnoredCandidateProcs on demand, and outline such adding on demand into dedicated TFPList.AddOnDemand. 2024-10-27 16:45:35 +00:00
florian
8b2ebd07bf * don't throw an internal error if a procedure is passed to a const formal parameter, resolves #40817 2024-06-13 22:32:54 +02:00
J. Gareth "Curious Kit" Moreton
1bba83cebb * Flags specific to TVecNode have been moved to their own field 2024-03-02 21:31:21 +01:00
Pierre Muller
37c3e86c7f Also reset check_valid_var after calling var_para_allowed 2024-02-23 15:48:50 +00:00
Pierre Muller
692754b422 Move test to end of possible conversion and add check_valid_var boolean variable 2024-02-17 21:33:52 +00:00
Pierre Muller
f39cfc75fc First attempt to fix bug report #40537 2024-02-17 21:33:52 +00:00
Michaël Van Canneyt
fe62b3ace8 * Introduce constwresourcestring - in unicode mode, resource strings are unicode strings, and must be streamed differently 2024-02-13 19:44:36 +01:00
Sven/Sarah Barth
981ec64666 * fix #40594: when assigning a nested function to a function reference don't check for the nested procvars parameter, because nested functions can be treated like anonymous functions here
+ added test
2024-01-22 22:27:33 +01:00
Jonas Maebe
2db4cae7aa nested procvars: support assignments when switch not active
Support assigning one nested procvar to another even when the nestedprocvars
modeswitch is not active. This can happen when the type was declared in a
different unit that was compiled with this modeswitch, or in internally
generated wrapper code (which uses "pure" objfpc mode)
2023-11-25 22:35:55 +01:00
Jonas Maebe
13346a42bc volatile: allow for assignments 2023-08-12 12:04:40 +02:00
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