Commit Graph

4771 Commits

Author SHA1 Message Date
svenbarth
54c1e638ad Fix for Mantis #22428.
* pgenutil.pas, generate_specialization:
  * return a generrordef instead of Nil when returning because of an error
  * always check "genname" for a generic count string as a mode ObjFPC generic specialized in a mode Delphi unit will already contain a "$X" suffix and only symname will be set.
+ add (corrected) test

git-svn-id: trunk@22462 -
2012-09-26 15:03:37 +00:00
Jonas Maebe
e3b97d99c6 * fixed memory leaks in case a TP-style object inherits from another object
type that contains managed types, but this child doesn't contain any
    managed type itself (since r16632, the parent should be considered as a
    field of the child in terms of needing initialization/finalization)

git-svn-id: trunk@22461 -
2012-09-26 14:26:00 +00:00
Jonas Maebe
10d4b8e66f * added "HaltOnNotReleased:=true;" so test exits with an error if not all
memory is released

git-svn-id: trunk@22459 -
2012-09-26 14:16:19 +00:00
svenbarth
582f1d04b8 Added %NORUN flag.
git-svn-id: trunk@22455 -
2012-09-25 10:27:34 +00:00
svenbarth
2414c55ca0 Fix for Mantis #21538.
* defcmp.pas, compare_defs_ext: 
  use the new genericparas list to check whether two specializations of the same generic can be considered equal
+ added test

git-svn-id: trunk@22454 -
2012-09-25 10:25:30 +00:00
svenbarth
03493a4d31 Added tests for now fixed Mantis #22427.
git-svn-id: trunk@22453 -
2012-09-25 10:10:28 +00:00
svenbarth
88af293155 Fix for Mantis #22160
The cause of the internal error was the following:
We have a generic in an unit ("A") which uses another unit ("B") in the implementation section and this other unit uses unit A in the interface section. Now the generic is specialized in the interface section of B. This leads to the problem that in unit A when it tries to load the globalsymtable of unit B that globalsymtable will be Nil, because parsing of the interface section is not yet finished. Thus the change in pgenutil.pas, specialization_init: if the unit is still "in_interface" the localsymtable needs to be used instead of the globalsymtable.

This doesn't necessarily lead to a compiling test though, as there is the following possibility:
Unit A contains a generic class/record (with methods) and uses unit B in the implementation section. This unit B also contains a generic class/record (with methods) and uses unit A in the implementation section. Both units contain a specialization of the other unit's generic outside of it's own generics (such that generate_specialization is fully triggered). Let's assume compilation starts with unit A and we reach the uses of unit B. Now compilation switches to unit B and completes as unit A is already registered and in compilation. The problem now is that the generic in unit A still contains unresolved forward declarations as the implementation section of A was not yet parsed which will lead to "forward declaration not solved" errors (Note: Delphi compiles this).

The solution to this is the following: if a generic is specialized from another unit which is not in state ms_compiled then the unit of the specialization needs to wait for the unit of the generic. So the specialization's unit adds itself into a list of waiting units of the generic's unit. Now inside "proc_unit" we need to check whether this module is waiting for other modules and if so avoid "finishing" the unit (which means generating the methods of the specialization, generating assembler code and ultimately freeing the scanner and PPU). Now when the generic's unit finishes we need to check whether other modules are waiting for it and finish them (of course it's a bit more complicated in reality, but that pretty much sums it up).

+ globstat.pas: Added an unit which handles the saving and restoring of the global state which was originally inside "parser.pas, compile" so that Don't Repeat Yourself (DRY) is respected.
* fmodule.pas, tmodule: 
  + add fields to keep track of the units the module is waiting for and which modules are waiting for the module
  + add field for the saved global state (raw pointer to avoid circles)
  + add field for the state which is needed to finish the unit (raw pointer to avoid circles)
  + move the code which was used in "parser.pas, compile" after a module was successfully compiled to the new virtual method "end_of_parsing"
+ fppu.pas, tppumodule.end_of_parsing:
  free the ppufile here
* pgenutil.pas:
  + add new procedure "maybe_add_waiting_unit" which adds the specialization's unit to the waiting list of the generic if that unit is not yet compiled
  * generate_specialization: call the new function when we add a new (true) specialization
  * specialization_init: instead of not adding implementation units at all check whether the unit is still parsing the interface section and add the localsymtable in that case
* pmodules.pas:
  * change "proc_unit" to a function which returns "true" if the unit was already finished (no need to wait for other units)
  + move the code from "proc_unit" from "generate_specialization_procs" on to a new procedure "finish_unit" which
  * this procedure is either called immediately in "proc_unit" if the unit does not need to wait for other units or from "finish_unit" itself if a unit that is waiting for the given unit does no longer wait for another module (special care is taken in proc_unit to avoid circles)
* parser.pas, compile:
  * correctly handle the case if an unit is not finished
  * use the new global state functionality from globstat.pas
  * pay special attention when calling "set_current_module" (see comment at that call)

+ add tests from 22160
+ add test for above mentioned "diamond" case

git-svn-id: trunk@22452 -
2012-09-25 09:45:25 +00:00
tom_at_work
71059475f8 GParMake also needs to get passed to allow completion of testsuite when some compilation options are incompatible to the default ones
git-svn-id: trunk@22438 -
2012-09-22 12:54:35 +00:00
Jonas Maebe
5ea03973d3 * reject assignments to vecn[rangen] (mantis #22941)
git-svn-id: trunk@22434 -
2012-09-21 22:42:30 +00:00
Jonas Maebe
64740049bf * fix for mantis #22796: add alignment padding to records before inserting
hidden parameters while parsing the interface, because they may depend on
    the padded size (since the size was not yet padded in the interface and
    padded in the implementation, this could result in differences)

git-svn-id: trunk@22414 -
2012-09-17 14:34:03 +00:00
Jonas Maebe
e4956552de * test from mantis #22796 (already works)
git-svn-id: trunk@22394 -
2012-09-15 13:40:17 +00:00
pierre
6f47ed44a0 * Remove stamps and MAKEFILETARGETS subdirectories for distclean
git-svn-id: trunk@22391 -
2012-09-14 14:34:20 +00:00
Jonas Maebe
dcdcc6988d * if an agregate contains unaligned fields, it has to be passed via memory
(mantis #22878)

git-svn-id: trunk@22390 -
2012-09-14 13:59:59 +00:00
florian
b72251389b * when forcing left into memory during code generation of a subscript node then the type of left must be passed else memory corruption happens
git-svn-id: trunk@22385 -
2012-09-13 19:22:42 +00:00
Jonas Maebe
1219797d94 * support LOC_(C)SUBSETREG/REF in gen_load_vmt_register() (mantis #22869)
git-svn-id: trunk@22380 -
2012-09-13 12:35:31 +00:00
Jonas Maebe
3b968b4b35 * don't allow overloading enum/int operations, because they should be
interpreted as internally define operations in case of enum type
    definitions in {$mode delphi} (mantis #22860)

git-svn-id: trunk@22377 -
2012-09-12 16:03:09 +00:00
Jonas Maebe
fe90823b01 * support the "overload" modifier for Objective-C methods
* only check whether the message identifier of an Objective-C method
    matches the one from a method with the same name in a parent class
    if the parameters match (todo: should be refined to "if the
    encoded Objective-C selector names match")

git-svn-id: trunk@22373 -
2012-09-11 21:58:40 +00:00
Jonas Maebe
e7cb2e9a28 * test for mantis #22807 (bug fixed in jasmin)
git-svn-id: trunk@22347 -
2012-09-06 18:50:29 +00:00
florian
8818b58e5d * Bsf/Bsr on x86 handle now correctly 0 as argument, resolves #22783
* generic Bsf implementations handle now correctly 0 as argument
* test extended

git-svn-id: trunk@22327 -
2012-09-05 13:51:45 +00:00
florian
59012afe26 * better heuristics to decide when a mul by a constant shall be replaced by shift/add/sub sequences
git-svn-id: trunk@22300 -
2012-09-03 13:39:52 +00:00
florian
2f8027c63f + more sophisticated code to optimize multiplications on arm
+ the multiplication optimization needs a popcnt function
+ simple test

git-svn-id: trunk@22299 -
2012-09-03 13:39:45 +00:00
florian
b782918434 * first draft to support the popcnt instruction, works so far for x86 with a real popcnt instruction
git-svn-id: trunk@22289 -
2012-09-02 20:59:39 +00:00
florian
728f53daa6 * test file for popcnt
git-svn-id: trunk@22288 -
2012-09-02 20:59:33 +00:00
Jonas Maebe
a5cb157091 * enable specifying the alignment mismatch of the frame/stack pointer
relative to the normal stack alignment of the target (e.g., when using
    ebp as framepointer, all addresses are offset 8 to the stack pointer) in
    the temp generator. This enables allocating temps/locals with the correct
    alignment as long as the required alignment is not bigger than the
    guaranteed stack pointer alignment (fixes mantis #15582 on systems where
    the stack pointer is at least aligned to 16 bytes; e.g., not yet on
    i386-platforms other than darwin)

git-svn-id: trunk@22277 -
2012-09-02 14:32:05 +00:00
Jonas Maebe
4cae00f97a * never use a linear table for enum<->string translation when two enums have
the same value (mantis #22570)

git-svn-id: trunk@22276 -
2012-08-31 18:51:59 +00:00
Jonas Maebe
ad054831bb * save/restore itype and implementsgetter fields of timplementedinterface
to/from ppu, because it can be required while resolving type casts
    (mantis #22741)

git-svn-id: trunk@22266 -
2012-08-29 16:07:55 +00:00
pierre
3c96d89a6b Add test for bug regarding {$pop} next to a statement
git-svn-id: trunk@22264 -
2012-08-29 14:30:14 +00:00
Jonas Maebe
f5de7e34d3 * only remove the calculation of unused parameters of inline routines if
they don't have explicit side-effects, and if -Oodeadvalues (part of -O4)
    is active (because it can result in the removal of range check errors,
    segmentation faults, etc)

git-svn-id: trunk@22254 -
2012-08-26 21:04:46 +00:00
Jonas Maebe
68d9e95120 * if the size of an operand is not explicitly forced in intel assembler
(e.g. via "dword ptr"), let the size of accessed fields in memory
    expressions override the default size (mantis #18019)

git-svn-id: trunk@22250 -
2012-08-26 17:05:31 +00:00
Jonas Maebe
198625af47 * fixed memory statistics after try_concat_free_chunk_forward() concatenated
some blocks, but the result was still not large enough to satisfy a
    reallocmem call (mantis #14315)

git-svn-id: trunk@22249 -
2012-08-26 15:29:44 +00:00
Jonas Maebe
193c7af57f * print literal e/E in formatfloat if not followed by +/- (remaining part of
mantis #22290)

git-svn-id: trunk@22248 -
2012-08-26 14:51:32 +00:00
Jonas Maebe
17c495595c * made variable public so got warning gets triggered
git-svn-id: trunk@22244 -
2012-08-25 21:32:38 +00:00
Jonas Maebe
4d0e4e1b56 * treat "[var + rip]" in intel assembler mode as addr_pic_no_got on x86-64
(mantis #22665)
  + support "[var wrt ..gotpcrel]" nasm/yasm syntax in intel assembler mode
    for GOT-relative accesses on x86-64, + give an error when trying to do
    this on win64 (it doesn't have a GOT)
  * moved code that give a warning when using GOT-relative accesses to
    static data on x86-64 from the AT&T reader to rax86 so it's also
    active for the Intel assembler reader
  + added warning when not using GOT-relative accesses (but plain
    RIP-relative instead) to global data on non-Win64 x86-64

git-svn-id: trunk@22243 -
2012-08-25 15:12:49 +00:00
Jonas Maebe
ab9d68ae3e * always use RIP-relative addressing in x86-64 assembler code
* abort if there's a warning (warnings for wrong/dangerous pic
    will be added in a later commit)

git-svn-id: trunk@22239 -
2012-08-25 15:12:24 +00:00
pierre
acfcb3d853 * Define slowcpu conditional for mips cpu, cuts execution time from 4 mins down to 20 secs
git-svn-id: trunk@22227 -
2012-08-24 07:47:00 +00:00
Jonas Maebe
85765364ee * properly compare parameter lists involving pointers to or classrefdefs of
forward defined types by maing sure that we always compare typesyms in
    that case instead of the forwarddefs (mantis #22705)

git-svn-id: trunk@22215 -
2012-08-23 20:58:22 +00:00
Jonas Maebe
288d1ec74a * support referencing "result" in nostackframe pure assembler routines if
the result location is a simple location (a single register/reference)
    (mantis #22490)
  * print an error when accessing "result" in a nostack pure assembler routine
    if the result location is not simple

git-svn-id: trunk@22166 -
2012-08-21 19:51:40 +00:00
florian
1da4c0c3ce * SinCos overloads added, resolves #22663
git-svn-id: trunk@22139 -
2012-08-19 22:09:03 +00:00
Jonas Maebe
504544e173 * fixed null-termination in StringToWideChar() if the buffer is larger than
the string (mantis #22669)

git-svn-id: trunk@22124 -
2012-08-19 13:48:02 +00:00
Jonas Maebe
f3ad4af343 * make sure valid_for_assign() returns false for inlined function bodies
(mantis #22613)

git-svn-id: trunk@22099 -
2012-08-16 19:22:17 +00:00
tom_at_work
65a4ab399e Fix use of FPC_OPT to build gparmake. The correct name of the parameter is FPCOPT. Regenerate makefile.
git-svn-id: trunk@22077 -
2012-08-13 20:45:39 +00:00
florian
5b90a02e75 * inherit nf_write/nf_modify in tcallnode.replaceparaload also when replacing parameters
git-svn-id: trunk@22075 -
2012-08-13 15:06:16 +00:00
Jonas Maebe
4d31fbc31d * also allow conversion of niln to forward-defined pointerdef
(mantis #22593)

git-svn-id: trunk@22026 -
2012-08-07 11:23:00 +00:00
Jonas Maebe
a63a603cc1 * allow conversion from niln to not-yet-fully-resolved classrefdefs
(mantis #22593)

git-svn-id: trunk@22025 -
2012-08-07 09:56:08 +00:00
Jonas Maebe
aad3ce960a * give an error when trying to give a parameter of a non-simple type a
default value (mantis #22343)
  * give an error when specifying an invalid default value (e.g. a
    floating point number for a longint parameter)

git-svn-id: trunk@22021 -
2012-08-06 20:13:20 +00:00
Jonas Maebe
3c1b82f9a0 * don't add value transformations for internal type casts from/to currency
(mantis #22561)

git-svn-id: trunk@22014 -
2012-08-05 15:36:44 +00:00
florian
49b03ea350 * readme updated
git-svn-id: trunk@22008 -
2012-08-04 09:50:13 +00:00
florian
89980e21f3 + binary objects for armhf
git-svn-id: trunk@22007 -
2012-08-04 09:47:37 +00:00
svenbarth
360592d1f4 Some corrections after the loosening of operator overloads:
* check "A op B" and "B op A" again for operators that can be commutative (all binary ones except shl, shr, div, mod, **, / and -)
* also check for Nil for classrefdefs if left side is a pointer (allows "TClass var" <>/= Nil again, after the above changes)
* don't allow overloads for "implicit pointer type <>/= pointer" and the other way around (this fixes non compiling Objective Pascal test tobjc21.pp and also the new toperator87.pp test)
* some formating corrections

+ added test for "TObject <> Pointer"
+ added test for "TClass <>/= Nil"

git-svn-id: trunk@21983 -
2012-07-29 12:38:09 +00:00
svenbarth
b0458b55a3 Loosen the restriction regarding operator overloads by applying a (modified) patch from JC Chu. This fixes Mantis #22359.
The changes are built up in a way that all operators on two given types are not allowed if a default implementation for that operator exists. This implies that there is a possibility to have a overload work for (in this order) type A and B, but not for B and A. This is for example the case for Set + Enum (which seems to have a default implementation) where Enum + Set is allowed. The added tests try to detect as many default implementations as feasible, but can't cover everything...

git-svn-id: trunk@21975 -
2012-07-26 18:02:01 +00:00