Commit Graph

459 Commits

Author SHA1 Message Date
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
svenbarth
ebfeb5b62a * fix for Mantis #30830: also remove unregistered specializations from the procsym's deflist when they're removed to avoid an access to freed data
+ added tests (adjusted original test plus a mode Delphi variant)

git-svn-id: trunk@35012 -
2016-11-29 14:12:02 +00:00
Jonas Maebe
179c1ab328 * changed ttemp*node.tempinfo^.flags to a private field, and added setters
and getters for the ttemp*node classes instead
   o this will allow descendants to prevent certain flags from being added
     or removed. E.g. for LLVM, certain temps must never be put in registers
     because it cannot typecast a value in a register from a non-record/array
     type to an array type without forcing it to memory (so if that is done
     on an lvalue, the result will be written to the memory temp instead of
     to the register)

git-svn-id: trunk@34358 -
2016-08-21 14:23:09 +00:00
svenbarth
e58488dc3e Fix for Mantis #29792.
htypechk.pas, tcallcandidates:
  * create_candidate_list: check the correct tableoptions for sto_has_overload flag

+ added test

git-svn-id: trunk@33211 -
2016-03-09 20:45:26 +00:00
svenbarth
05174f3e67 Fix for Mantis #29546.
htypechk.pas, tcallcandidates:
  * create_candidate_list: don't check whether the pd is a specialization if the owner is valid; happens if a generic method is used more than once (which should happen here and then :P )

+ added test

git-svn-id: trunk@33037 -
2016-01-31 17:14:44 +00:00
Károly Balogh
4e14c292b0 fixed a the check for pd.owner being assigned before defererencing it. this fixes a reproduceable compiler crash I ran into recently
git-svn-id: trunk@32965 -
2016-01-18 12:42:24 +00:00
Jonas Maebe
9258b5d76b + non-functional 128 bit integer types (inaccessible from Pascal), for use
in the LLVM high level code generator to implement overflow checking

git-svn-id: trunk@32735 -
2015-12-26 20:00:33 +00:00
svenbarth
529677cc79 ncal.pas:
* extend tcallnode with the ability to pass a tspecializationcontext so that tcallcandidates can do a final specialization
  * the final procdef is registered at the end of tcallnode.pass_typecheck

git-svn-id: trunk@31763 -
2015-09-18 14:48:54 +00:00
svenbarth
2e24d6dffb htypechk.pas:
* extend tcallcandidates by the ability to handle generic procdefs
pgenutil.pas:
  + export check_generic_constraints

git-svn-id: trunk@31760 -
2015-09-18 14:37:47 +00:00
Jonas Maebe
c27807ee63 * resolve formal/anonymous external classes before comparing parameters to
overloaded routines

git-svn-id: trunk@31458 -
2015-08-30 14:33:01 +00:00
Jonas Maebe
61ddaab091 * never keep a value in a register for llvm if it's typecasted on the
left-hand side of an assignment (you can't typecast lvalues in llvm)

git-svn-id: trunk@30708 -
2015-04-25 15:50:55 +00:00