Commit Graph

172 Commits

Author SHA1 Message Date
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
Charles Averill
cd9ed54d35 Add string constant values to stringconstn nodes in parse tree output 2024-01-21 16:39:09 +00:00
Jonas Maebe
82f025e9e7 trealconstnode.printnodedata: fix currency values getting written to stdout 2023-12-04 22:52:39 +01:00
Jonas Maebe
6dc47c71fb tstringconstnode.changestringtype: fix buffer overrun
Found by asan
2022-07-06 22:25:05 +02:00
florian
a285500d36 * patch by Rike: Use reverse_longword instead of manually reversing longword, resolves #39720 2022-05-13 22:38:03 +02:00
Jonas Maebe
3da54dcf9f Symbolic constants: don't range check on use
If these constants are defined with an explicit type, they are already
truncated/checked at that point. If we range check them again on use, we
may get errors because at that point there is no explicit type cast
any more.
2022-04-02 13:26:44 +02:00
Yuriy Sydorov
07dcd22b1c * sizeof(array) and length(array) must return sizeUint in case the array
size does not fit in sizeint. This fixes a range check error during
  compilation on small CPU targets where allowed array size is 64K, but
  sizeint is 32K max.
2021-08-16 21:54:46 +03:00
florian
60c8b71bae * string constants have a size of 0, resolves #38504
git-svn-id: trunk@48759 -
2021-02-21 18:46:00 +00:00
florian
4bec57702f * handle generic with ord call of sub-range and enumeration data excluding 0 correctly, resolves #38412
git-svn-id: trunk@48452 -
2021-01-29 21:31:59 +00:00
florian
e94fb2edc3 * better writing of ordinal const. nodes
git-svn-id: trunk@47436 -
2020-11-16 21:47:18 +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
florian
4de6b3e6b9 * do not crash when an unsupported code page is encountered, resolves #35581
git-svn-id: trunk@43764 -
2019-12-23 21:44:50 +00:00
florian
86d8e79e86 * fix some currency issues, resolves #33963 and #36179
git-svn-id: trunk@43620 -
2019-12-01 20:24:00 +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
ac1e0f96bd * replaced tentryfile.get/putsmall/normalset() with a common tget/putset
that expects an open array of byte, and use it for all sets
   o since all sets need to be typecasted to an array type of the appropriate
     size, we'll get a compilation error in case this needs to be done and
     that also tells us at the same time that the ppu version will need to
     be increased
  * enabled {$packset 1} for the compiler, as this is now safe with the above
    changes

git-svn-id: trunk@43407 -
2019-11-06 21:50:19 +00:00
svenbarth
797e336222 * fix writing of floating point attribute parameters
git-svn-id: trunk@42489 -
2019-07-24 20:32:17 +00:00
svenbarth
55d5bdc98d + add methods for the const nodes to directly emit their constant data to a constant builder
Note: reduce code duplication, especially for the tsetconstnode (with its descendant tcgsetconstnode)

git-svn-id: trunk@42389 -
2019-07-12 22:07:01 +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
pierre
243c967967 Commit of new debug feature implemented by J. Gareth Moreton
Allows compilation of compiler using -dDEBUG_NODE_XML
  which will generate a NAME-node-dump.xml file for each 
  unit, program or library compiled,
  containing a XML description of the nodes handled during
  compilation of the unit, program or library.

git-svn-id: trunk@42271 -
2019-06-22 14:08:47 +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
yury
e5c2d13671 * Do not set pi_needs_got in current_procinfo.flags at the node level, since the GOT usage can only be estimated there. Instead set the pi_needs_got flag at places where the GOT register is accessed during the code generation. This eliminates generation of the unneeded initialization of the GOT register and fixes linker errors when the _GLOBAL_OFFSET_TABLE_ symbol is referenced but no actual GOT references are present.
git-svn-id: trunk@41460 -
2019-02-25 13:35:40 +00:00
Jonas Maebe
70cadc7694 * fixed string constant length when going from utf-8 to single-byte code page
(mantis #33666, patch by engkin)

git-svn-id: trunk@40637 -
2018-12-24 22:21:40 +00:00
florian
68eb921d46 * broken compilation after r39347 fixed
git-svn-id: trunk@39349 -
2018-06-30 12:30:25 +00:00
Jonas Maebe
4da6039f40 * simplify empty-dynamic-string-to-pointer (non-p(wide)char) type conversions
so that they cannot result in "cmp const, const" at the assembler level
    (mantis #33548)

git-svn-id: trunk@38662 -
2018-04-02 18:35:00 +00:00
Jonas Maebe
8cfe7e0a0c * when creating a realconstn, cast the value to the specified type
(mantis #25121)
   o note that this means that single_const1/single_const2 will now be rounded
     to single, instead of staying the at maximum precision
   o fixed FahrenheitToCelcius() to handle this change correctly

git-svn-id: trunk@37911 -
2018-01-04 20:51:36 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
Jonas Maebe
a2bd07bfd6 * fixed compilation of 64-bit cross-compilers on 32 bit platforms
(mantis #31487)

git-svn-id: trunk@35532 -
2017-03-06 21:37:34 +00:00
florian
13b3866552 * convert (s*[const. set])<>/=[] for var. sets into or'ed in nodes, if const. set contains only a few elements
git-svn-id: trunk@35526 -
2017-03-05 20:29:22 +00:00
Károly Balogh
5426c11611 marked a few uses of TConstExprInt as const during parameter passing, to avoid a few unnecessary record copying
git-svn-id: trunk@35509 -
2017-03-03 17:29:59 +00:00
Jonas Maebe
1afab1ab69 * moved the floating point constant range checking code from
pass_generate_code to pass_typecheck, so that it's also used by targets
    that override pass_generate_code (fixes webtbs/tw16315b for LLVM)

git-svn-id: trunk@35021 -
2016-11-29 21:54:33 +00:00
Jonas Maebe
974c2363c0 - removed tdataconstnode, as it is no longer used and is not type safe.
Use a typed constant builder instead.

git-svn-id: trunk@34155 -
2016-07-19 14:30:42 +00:00
Jonas Maebe
a65ab73e8b * support unicodestring constants in "case string of" (mantis #29353)
git-svn-id: trunk@32970 -
2016-01-20 21:11:26 +00:00
florian
495b7181a8 + write the value of a pointer constant node in printnodedata
git-svn-id: trunk@31469 -
2015-08-31 20:03:47 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
nickysn
22acb2e44b * moved the i8086 specific code from tpointerconstnode.create to the i8086
descendant class

git-svn-id: trunk@27285 -
2014-03-25 22:00:23 +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
99eadb91b3 * run CheckAndWarn to get proper locations for warnings about uninitialized variables
* several fixes to liveness analysis
* get rid of old version defines
+ tests

git-svn-id: trunk@26159 -
2013-12-01 17:01:51 +00:00
Jonas Maebe
90fb63db26 * also compare the type of tordconstnode in docompare, so that the node CSE
doesn't replace e.g. 32 bit and 64 bit constants with the same value by
    a single 32 bit constant (mantis #25090)

git-svn-id: trunk@25593 -
2013-09-28 14:12:50 +00:00
svenbarth
b57a587842 Fix for Mantis #24903.
ncon.pas, tstringconstnode:
  * buildderefimpl: don't build the deref if we don't need to
  * derefimpl: do not try to resolve the deref if it wasn't stored at all

git-svn-id: trunk@25329 -
2013-08-22 20:18:14 +00:00
Jonas Maebe
fb8fb29574 * record/use the code page of string constants typecasted to an ansistring
type with a non-default code page
   TODO: ensure that string constants typecasted to ansistring become
     ansistrings rather than typeless string constants

git-svn-id: trunk@25207 -
2013-08-02 13:23:32 +00:00
nickysn
ed29f7a92d + far pointer support in tpointerconstnode
git-svn-id: trunk@24566 -
2013-05-24 12:41:53 +00:00
florian
9375529430 + put guids in a constant pool as well
git-svn-id: trunk@24061 -
2013-03-29 18:48:55 +00:00
florian
f6b78719bc * fix trealconstnode.dogetcopy and trealconstnode.docompare, taking care of all fields, resolves #23486
git-svn-id: trunk@23241 -
2012-12-28 14:16:09 +00:00
sergei
c766c50907 * Proper fix for SPARC cycling with -dCHECK_PIC, pi_needs_got additionally must be set in following cases:
1) tguidconstnode.pass_1 (location is LOC_CREFERENCE)
  2) tonnode.pass_1 (generic secondpass references VMT of exception class)
  3) Conversion from unsigned to floating-point involves 'magic constant' as GOT-relative data object.
  4) Case jumptable address is loaded relative to GOT.

(1) and (2) also provide more accurate setting of pi_needs_got for all targets.

git-svn-id: trunk@23188 -
2012-12-18 17:56:56 +00:00
pierre
bc04e83b25 Add pi_needs_got to current_procinfo.flags in pass_1 method if a label reference is used
git-svn-id: trunk@22448 -
2012-09-24 15:39:26 +00:00
Jonas Maebe
834026bfb5 * synchronised with trunk up to r21067
git-svn-id: branches/jvmbackend@21068 -
2012-04-26 21:24:20 +00:00
paul
a26bc50ca6 compiler: change ShortString->(Some)String and AnsiString->(Some)String overload precedence both for variables and string constants, change unicode constant type from widestring to unicodestring (Delphi compatibility)
new ShortString->(Some)String precedence: ShortString, UTF8String, AnsiString, AnsiString(CodePage) and RawByteString, UnicodeString, WideString and other string types
new AnsiString->(Some)String precedence: RawByteString, UTF8String, AnsiString, AnsiString(CodePage), UnicodeString, WideString, ShortString and other string types

The new logic makes UTF8String more preferrable than other AnsiString types, AnsiString more preferrable than other  AnsiStrings(codepage) and also makes UnicodeString more preferrable than WideString.

git-svn-id: trunk@21057 -
2012-04-26 02:33:57 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
Jonas Maebe
d1acb76df8 * don't replace "expr1 or expr1" or "expr1 and expr1" with just "expr1"
if expr1 has sideeffects. This can't be done safely even in case of
    short boolean evaluation, because expr1 may return the inverse the
    second time its called (and "0 or 1" is not the same as "0", and
    neither is "1 and 0"), based on comment by Michael Karcher
  * perform a full string compare when comparing stringconstnodes
    before the string constant labels have been generated (patch by
    Michael Karcher, mantis #21255)

git-svn-id: trunk@20485 -
2012-03-09 20:26:32 +00:00
Jonas Maebe
74e721517d * keep track of the type of symbolic floating point constants rather
than always forcing them to bestreal (mantis #21151)

git-svn-id: trunk@20190 -
2012-01-28 18:38:06 +00:00