Commit Graph

445 Commits

Author SHA1 Message Date
florian
19c2e948b9 * nil =/<> dyn. array is a valid expression, so isbinaryoperatoroverloadable needs to take care of it, resolves #39933
(cherry picked from commit 2396b36c21)
2022-10-04 22:18:35 +02:00
svenbarth
66fa732720 Merged revision(s) 47634, 47655 from trunk:
* 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... :/
........
* with the recent ShortString changes this test is no longer needed as it was added exactly to check the condition I removed, so disable it for 3.2.1 and newer (as I want to merge these changes back to fixes)
........

git-svn-id: branches/fixes_3_2@49055 -
2021-03-26 06:18:40 +00:00
florian
7eeaf5d5a0 -- Zusammenführen von r46973 in ».«:
U    compiler/htypechk.pas
U    compiler/ncal.pas
A    tests/webtbs/tw37796.pp
-- Aufzeichnung der Informationen für Zusammenführung von r46973 in ».«:
 U   .

git-svn-id: branches/fixes_3_2@47908 -
2020-12-30 14:22:51 +00:00
svenbarth
8a249b2d74 Merged revision(s) 44256-44257, 44746, 45329 from trunk:
* fix for Mantis #36706: only link a library against the dynamic loader if we're not linking against the C library anyway

Note: I did not yet find a case where we *do* need to link a library against the loader; this will have to be investigated further, but for 3.2.0 this is safest
........
* fix for Mantis #36738: when copying a record using its copy operator we assume that we've copied the whole record; this way managed records inside non-managed records are handled correctly
+ added (adjusted) test
........
* when checking for an existing operator overload for the assignment operator, check for the correct variant (explicit or not) matching the overload
+ added tests
........
* GetLoadErrorStr (currently) returns a ShortString, so avoid a useless conversion to AnsiString
........

git-svn-id: branches/fixes_3_2@47771 -
2020-12-13 21:52:13 +00:00
svenbarth
92a580d3a6 Merged revision(s) 41868-41869 from trunk:
* 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)
........
* fix for Mantis #35348: correctly handle symbols that aren't parameter types (e.g. default values)
+ added test
........

git-svn-id: branches/fixes_3_2@47587 -
2020-11-25 21:39:12 +00:00
Jonas Maebe
3129605195 --- Merging r40180 into '.':
U    compiler/ninl.pas
--- Recording mergeinfo for merge of r40180 into '.':
 U   .
--- Merging r40216 into '.':
U    compiler/htypechk.pas
G    compiler/ninl.pas
U    tests/tbf/tb0258.pp
A    tests/tbf/tb0259.pp
A    tests/tbf/tb0260.pp
A    tests/tbs/tb0653.pp
--- Recording mergeinfo for merge of r40216 into '.':
 G   .
--- Merging r40217 into '.':
U    compiler/systems/t_bsd.pas
--- Recording mergeinfo for merge of r40217 into '.':
 G   .
--- Merging r40218 into '.':
G    compiler/systems/t_bsd.pas
--- Recording mergeinfo for merge of r40218 into '.':
 G   .

git-svn-id: branches/fixes_3_2@44000 -
2020-01-19 19:20:31 +00:00
marco
037583ef4e --- Merging r40654 into '.':
U    compiler/msg/errore.msg
--- Recording mergeinfo for merge of r40654 into '.':
 U   .
--- Merging r40656 into '.':
U    compiler/pdecvar.pas
A    tests/tbf/tb0266a.pp
A    tests/tbf/tb0266b.pp
--- Recording mergeinfo for merge of r40656 into '.':
 G   .
--- Merging r41308 into '.':
U    tests/webtbs/tw35027.pp
--- Recording mergeinfo for merge of r41308 into '.':
 G   .
--- Merging r41829 into '.':
U    compiler/htypechk.pas
U    compiler/ncal.pas
A    tests/tbs/tb0656.pp
--- Recording mergeinfo for merge of r41829 into '.':
 G   .
--- Merging r42511 into '.':
U    packages/rtl-objpas/src/inc/rtti.pp
U    rtl/objpas/typinfo.pp
U    tests/test/trtti19.pp
--- Recording mergeinfo for merge of r42511 into '.':
 G   .

# revisions: 40654,40656,41308,41829,42511

git-svn-id: branches/fixes_3_2@43410 -
2019-11-07 10:04:13 +00:00
Jonas Maebe
3ac703506c * rest of the previous accidental partial commit
git-svn-id: branches/fixes_3_2@41250 -
2019-02-07 19:56:21 +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
Jonas Maebe
bad1b2a1c1 * fix for issue introduced in r28862: the compiler considered also
dynamic arrays and fixed-length static arrays when looking for
    overloads of array constructors, while these are not valid in
    such cases (and it also gave an error afterwards when trying to
    actually use them). This caused a lot of spurious "can't select
    which overloaded routine to call" errors when using many JVM
    routines

git-svn-id: trunk@29393 -
2015-01-04 19:41:21 +00:00
florian
4289dd667d * managed types cause a different warning/hint when they are
used uninitialized, so users can turn off these messages if they want, resolves #24601 and #26403

git-svn-id: trunk@29295 -
2014-12-14 20:48:54 +00:00
Jonas Maebe
dc4a2a59f7 * initialise mineq before exiting the parameter checking loop for open array
parameters (bug in r28862, mantis #26976)

git-svn-id: trunk@28954 -
2014-10-31 20:45:54 +00:00
Jonas Maebe
f1c45eeae3 * support passing [nil] to an array of class/objcclass/javaclass/intf/...
in {$mode objfpc} (mantis #19452)

git-svn-id: trunk@28862 -
2014-10-17 16:10:55 +00:00
svenbarth
244ac12794 Fix for Mantis #26615.
htypechk.pas, tcallcandidates:
  * collect_overloads_in_struct: we need to check the deftyp of the extended def for record- or objectdef, not the deftyp of the helper which will always be objectdef anyway.

+ added test

git-svn-id: trunk@28572 -
2014-09-01 07:18:02 +00:00
sergei
1744988962 * Modified behavior of CExtended type in overload selection: it is made more compatible to Extended than to Double and Single. Also an Extended parameter selects a CExtended overload (if available) instead of Double.
+ Test.

git-svn-id: trunk@27366 -
2014-03-30 07:31:58 +00:00
florian
3e4198ea45 * take care of dyn. arrays in cse
git-svn-id: trunk@26740 -
2014-02-08 21:47:46 +00:00
florian
1366498255 + nf_addr_taken: it marks nodes which address is taken
+ check if tnodeflags is 4 bytes or less
* do not do cse on expressions which address is taken

git-svn-id: trunk@26713 -
2014-02-07 20:40:42 +00:00
Jonas Maebe
89d97a3c2e * only consider tc_pointer_to_array typeconversions to determine whether a
pointer->array type conversion implies an implicit dereference operation
    (mantis #25622)

git-svn-id: trunk@26608 -
2014-01-28 20:14:24 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
florian
6f03d04fe1 * when using a pointer as array, the pointer is never written, only read
git-svn-id: trunk@25964 -
2013-11-06 21:10:30 +00:00
svenbarth
798bb91e90 Extract tdef.is_related plus its overrides in tobjectdef, trecorddef and tstringdef into a new function def_is_related in unit defcmp.
defcmp.pas:
  + add new function "def_is_related" which combines the "is_related" overloads of "tobjectdef", "trecorddef" and "tstringdef" (it returns "false" for other def types which is what "tdef.is_related" did)
  * compare_defs_ext & compatible_childmethod_resultdef: change call from "x.is_related" to "def_is_related(x,...)"
symtype.pas, tdef:
  - remove "is_related" method
symdef.pas:
  - remove "is_related" in "tobjectdef", "trecorddef" and "tstringdef"
  * tobjectdef.needs_inittable: for checking whether a Corba interface somehow inherits from a IInterface don't use "is_related" anymore (we want to avoid the dependency after all), but mimic the necessary functionality of "def_is_related"
htypechk.pas, nadd.pas, ncal.pas, ncnv.pas, ngtcon.pas, nld.pas, optvirt.pas, pdecobj.pas, pdecvar.pas, pexpr.pas, pgenutil.pas:
  * change call from "x.is_related" to "def_is_related(x,...)"
symtable.pas
  + use unit defcmp
  * change call from "x.is_related" to "def_is_related(x,...)"
jvm/njvmcnv.pas, jvm/njvmflw.pas:
  * change call from "x.is_related" to "def_is_related(x,...)"

git-svn-id: trunk@25847 -
2013-10-25 19:44:27 +00:00
svenbarth
168c9d152f Small optimization for the search of operator overloads. Add a flag "sto_has_generic" to all symtables that contain an operator overload (the flag propagates up the owning symtables) and check this flag when searching for units with operators.
symconst.pas:
  + add "sto_has_operator" to "tsymtableoption"
pdecsub.pas:
  + include the flag "sto_has_operator" for all operator declarations and their owning symtables
htypechk.pas, tcallcandidates:
  * create_candidate_list: only check for operator overloads if the record does indeed declare some
  * collect_overloads_in_units: only check for operator overloads if the unit does indeed declare some
utils/ppudump.pp:
  + respect the new "sto_has_operator" flag

git-svn-id: trunk@23688 -
2013-03-04 16:02:18 +00:00
florian
b43b4bb455 + pseudo procedure aligned: tells the compiler to assume that the given parameter is naturally aligned, counterpart of unaligned
git-svn-id: trunk@23310 -
2013-01-04 19:13:24 +00:00