Commit Graph

109 Commits

Author SHA1 Message Date
Jonas Maebe
12bde4e903 WPO: fix dead code detection, and handle procvars
Extend dead code detection to not only look for the main mangled name, but also
for any aliases before deciding that a routine has been dead-stripped.

Assume objects/classes can also be constructed if the address of one of their
constructors or of the TObject.NewInstance class method has been taken.

Resolves #40204
2023-03-24 21:22:18 +01:00
florian
7affd78904 * do not throw an internal error on typed constants with wrong element count, resolves #40066 2022-12-30 21:53:04 +01:00
florian
3f7bf0fd70 * stop generation of typed array constants if the size does not match, resolves #39980 2022-11-01 21:16:31 +01:00
florian
3fa77a4f62 * fix life information propagation for while loops, resolves #39971
* warnings/errors fixed which are caused by the new life information propagation
  + test
2022-10-24 22:13:43 +02:00
Sven/Sarah Barth
a93942cd27 * correctly convert a single WideChar to a PChar constant with the correct code page
+ added test
2022-08-28 21:53:44 +02:00
Sven/Sarah Barth
e5957b1ef0 * fix #39875: when a WideString constant is used to initialize a PChar the constant needs to be converted to the current code page
+ added test
2022-08-26 18:05:13 +02:00
Jonas Maebe
70908b1449 llvm: support for adding/subtracting constants to pointers in typed constants
Fixes webtbs/tw34027 for llvm
2022-05-29 13:33:27 +02:00
Jonas Maebe
83604b709c ngtcon: fix def of emitted vmt in procedure of object typed constants
Fixes compilation of tests/test/tprocvar17 with the LLVM backend, and probably
some other tests as well
2022-05-28 11:21:39 +02:00
Sven/Sarah Barth
6a9b4a1b13 + apply patch by Blaise.ru: allow initialisation of method pointers with class methods (when class types are
known at compile time)
* adjust error message when a method pointer isn't suitable
+ add tests
2022-05-26 21:42:55 +02:00
Jonas Maebe
f1bcd02aaf Typed const builder: store tsym
Useful for LLVM debug info generation
2022-05-13 22:49:02 +02:00
Jonas Maebe
b1f85792d7 Symbolic constants: don't range check on in use in typed constants
Same as 3da54dcf9f, but this type when used in type constant definitions
like record fiels
2022-04-03 11:20:10 +02:00
Jonas Maebe
ab01b0ebd7 Typed constants: no internalerror on failure
Don't check whether the expression queue is empty in the destructor in case
there was an error. Also improved error messages (constant expression instead
of variable expression expected).

Resolves #39393
2021-10-03 21:46:23 +02:00
Károly Balogh
0ca1e2fb42 * attempt to fix bitpacked records with qwords in them (tw36156) when cross-compiling to big endian targets from x86. essentially the x86 shifting workarounds in the code already weren't covering all corner cases.
git-svn-id: trunk@48773 -
2021-02-21 23:00:41 +00:00
florian
d0910b5ac8 * allow sub/add nodes in constant pointer expressions, resolves #34027
git-svn-id: trunk@48514 -
2021-02-05 22:10:27 +00:00
florian
637976e83f * patch by Marģers to unify internal error numbers, resolves #37888
git-svn-id: trunk@47103 -
2020-10-13 19:59:01 +00:00
florian
df6baa888b * another error message changed into a better one
git-svn-id: trunk@46947 -
2020-09-24 20:09:33 +00:00
florian
dfc485c4f4 * better error message in case of illegal nodes for string constants, resolves #34054
git-svn-id: trunk@46931 -
2020-09-23 20:25:04 +00:00
Károly Balogh
2de0be9633 * attempt to correct bitpacked arrays on big-endian systems after r43186. this fixed tparray13 test on m68k at least
git-svn-id: trunk@46347 -
2020-08-09 21:31:18 +00:00
Jonas Maebe
4ba19f5418 * add support for creating non-address-only procvars to
cprocvar.getreusableprocaddr()

git-svn-id: trunk@44516 -
2020-04-02 21:21:36 +00:00
Jonas Maebe
d23c7980aa * properly perform (or not) range/overflow checking when performing constant
propagation into inlined routines, regardless of the range/overflow
    checking state at the caller site

git-svn-id: trunk@43436 -
2019-11-10 12:00:05 +00:00
Jonas Maebe
33c4a5dda7 * don't try to bitpack arrays of non-ordinals (mantis #36157)
git-svn-id: trunk@43187 -
2019-10-13 11:11:28 +00:00
Jonas Maebe
51c6ebfe54 * work around broken x86 shifting in bitpacked value calculation
(mantis #36156)

git-svn-id: trunk@43186 -
2019-10-13 10:47:31 +00:00
Jonas Maebe
3fee990218 * on Mach-O, PECOFF and ELF platforms, write local symbols as hidden/
private_extern (or plain global in case of PECOFF, as the effect is
    the same there): visible across object files, but they become local
    when linked into a binary/library. This enables cross-unit inlining
    of functions accessig implementation-only symbols.

git-svn-id: trunk@42340 -
2019-07-07 21:33:43 +00:00
Jonas Maebe
c038e4c3f2 * relaxation of r42272: again only show warnings rather than errors for
out-of-range constants, because of the comments mentioned in #35753
    (except for enums, as apparently Delphi does the same)
  * added range check warnings about explicit type casts that throw away
    bits (e.g. byte($fff)), without giving warnings for most common cases
    (like cardinal(-1))
  * fixed masking/sign exting constant array indices (must be based on index
    range type size/signedness rather than on array size/"signedness")

git-svn-id: trunk@42275 -
2019-06-23 14:12:33 +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
Jonas Maebe
97b40dc16d * fixed dynamic array constants for llvm
git-svn-id: trunk@40383 -
2018-11-28 19:23:25 +00:00
pierre
b64e9700aa Avoid range errors or overflows on for AVR cpu, when computing address offsets
git-svn-id: trunk@40378 -
2018-11-27 10:21:37 +00:00
pierre
e49025a086 More -CriotR fixes:
* entfile.pas: Change PPU header falgs filed from longint to dword.
  * ngtcon.pas: Change local variable startoffset type to aword.
  * omfbase.pas: Avoid calling move with a nil string s indexed as s[1],
    to avoid a range check error.
  * owomflib.pas: Disable range check explicitly in hash computation.
  * utils/ppuutils/ppudump.pp: Adapt to flags type change in entfile.pas

git-svn-id: trunk@40163 -
2018-11-01 21:58:54 +00:00
Jonas Maebe
2a3eeab96d * support for constant char/bool/enum indices in typed constant
index expressions (mantis #34055)
  * prevent all indirect structure indexing instead of only
    ansi/wide/unicodestrings

git-svn-id: trunk@40010 -
2018-10-21 18:48:41 +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
b7cc225149 * revert r39043 and r39045 which disallow static array constants inside dynamic constants for Delphi modes
git-svn-id: trunk@39078 -
2018-05-21 08:13:17 +00:00
svenbarth
dcdb151add * prohibit static array constants inside dynamic array constants for Delphi modes
+ added test

git-svn-id: trunk@39045 -
2018-05-20 11:50:27 +00:00
svenbarth
a29a6abc55 + add support for Delphi's dynamic array constant syntax ("[...]") in Delphi modes
git-svn-id: trunk@39042 -
2018-05-20 11:50:19 +00:00
svenbarth
08dd4e5445 + add support for dynamic array constants
+ added test

git-svn-id: trunk@39041 -
2018-05-20 11:50:16 +00:00
florian
0caccdc238 * fix range check error
git-svn-id: trunk@36945 -
2017-08-20 15:21:48 +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
yury
5405a4727a * Removed unused vars.
git-svn-id: trunk@35535 -
2017-03-07 08:56:07 +00:00
Jonas Maebe
7af2663ed1 * fixed writing the VMT field of TP-style objects for typed constants if it
comes after the last defined field (previously, we emitted a bunch of
    superfluous zero-bytes after that field due to bad accounting regarding
    the last emitted field)
   o fixes webtbs/tw1365.pp for LLVM, and removes junk bytes for all targets

git-svn-id: trunk@35019 -
2016-11-29 21:54:27 +00:00
Jonas Maebe
9727f289b1 + tcalo_apply_constalign option to specify that the alignment should be
modified by applying user alignment settings (so it can be only done for
    user-defined data, not not for internally generated data)
   o set this option for user-defined data

git-svn-id: trunk@34633 -
2016-10-06 06:25:05 +00:00
Jonas Maebe
de60bfab9c * make the string data of pchar constants read-only (mantis #30666)
git-svn-id: trunk@34594 -
2016-10-02 12:56:40 +00:00
Jonas Maebe
ad0299e0cd * cleanup of r34444
git-svn-id: trunk@34482 -
2016-09-10 16:16:48 +00:00
Jonas Maebe
997a958f72 * fixed r34439 for big endian
git-svn-id: trunk@34444 -
2016-09-07 16:09:10 +00:00
Jonas Maebe
473cec9d85 * converted tnodeutils.InsertRuntimeInits() to the high level typed const
builder

git-svn-id: trunk@34443 -
2016-09-07 16:09:06 +00:00
Jonas Maebe
26f6d2f39d * emit smallsets as a single byte/word/cardinal, since that is how they
are handled in the code generator (and ncgcon) as well

git-svn-id: trunk@34439 -
2016-09-06 21:28:30 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
Jonas Maebe
68cbbe677a * fixed type information for C-block typed constants (fixes
tests/test/tblock1.pp for llvm)

git-svn-id: trunk@34152 -
2016-07-19 14:30:33 +00:00
Jonas Maebe
0311528502 * always write bitpacked typed constant arrays as a multiple of bytes rather
than of their loadsize, because otherwise if they are e.g. part of a record
    they would occupy more space than allowed
   o adapted llvm code to deal with the fact that bitpacked arrays are now
     always arrays of bytes rather than arrays of integers with the same size
     as their loadsize -- this also fixes several type inconsistencies
     detected by llvm

git-svn-id: trunk@34125 -
2016-07-14 15:23:07 +00:00
Jonas Maebe
c71bc54785 * when emitting the procedure address part of a complex procvar, type
that address as an "address-only" procvar instead of supposedly
    emitting a complex procvar itself as the address part of that same
    complex procvar type (part of fixing test/tmaclocalprocparam4e.pp
    for llvm)

git-svn-id: trunk@34117 -
2016-07-14 15:18:01 +00:00
Jonas Maebe
8e2607d96d * data for bitpacked arrays is part of an aggregate
git-svn-id: trunk@34032 -
2016-06-30 15:33:40 +00:00