Commit Graph

499 Commits

Author SHA1 Message Date
florian
be2ab84474 * make actualtargetnode a normal procedure using pointers to node so it can be used also when replacing nodes
+ replacenode to replace nodes inline

git-svn-id: trunk@25013 -
2013-06-29 22:20:30 +00:00
florian
0e41df598e * merge i8086 branch by Nikolay Nikolov
git-svn-id: trunk@24324 -
2013-04-25 20:23:51 +00:00
florian
075abd6220 + support of stackframesize for arm thumb
+ estimatedtempsize to get a good estimatation for architectures which require to know the stack size before

git-svn-id: trunk@24188 -
2013-04-07 21:00:38 +00:00
nickysn
889e8650f1 * fixed compiler crash due to infinite recursion when compiling boolean to longint conversion on a 16 or 8-bit CPU
git-svn-id: branches/i8086@24135 -
2013-04-03 00:16:41 +00:00
Jonas Maebe
0ad9f345dd * handle explicit typecasts of procdefs to procvardefs always via
proc_to_procdef, because a methodpointer may have to be discarded

git-svn-id: trunk@23929 -
2013-03-19 13:23:51 +00:00
paul
fe4b5ea82d compiler: convert unicode constants which are > 127 to AnsiString (except UTF8String) in runtime to prevent conversion to wrong codepage (read issue #0021195)
git-svn-id: trunk@23613 -
2013-02-14 09:01:07 +00:00
paul
5d74e0578a compiler: remove unused variables and unneeded assignments
git-svn-id: trunk@23467 -
2013-01-21 01:24:36 +00:00
pierre
78d31eb3cd Add missing of pi_needs_got found by sparc compiler compiled with -dCHECK_PIC
git-svn-id: trunk@22548 -
2012-10-05 15:02:47 +00:00
florian
ca5fabda6d * cleanup some unused units from uses clauses
git-svn-id: trunk@22433 -
2012-09-21 18:53:46 +00:00
florian
e18a9cccaa * fix expectlocs for method pointers
git-svn-id: trunk@22342 -
2012-09-06 15:12:02 +00:00
Jonas Maebe
c25d9d5e06 * do not search for overloaded operators while parsing constant declarations,
since they require function calls and it's not possible to call functions
    inside constant blocks (and because current_procinfo is not necessarily
    valid when a constant block is parsed, this moreover crashes the compiler)

git-svn-id: trunk@22018 -
2012-08-06 20:13:06 +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
Jonas Maebe
44fd18a041 * correctly set expectloc for bool->cbool type conversions (mantis #22502)
git-svn-id: trunk@21973 -
2012-07-26 14:50:28 +00:00
Jonas Maebe
99c22b87c1 * moved transformation of char-to-chararray type conversion into helpers
to first pass, fixes tbf/tb0215

git-svn-id: trunk@21846 -
2012-07-10 13:05:45 +00:00
Jonas Maebe
9e0184884e * correctly change the signdness information of tordconstnodes that are
simplified via typeconvnode (corrects resultdef of "qword(1) shl 33",
    mantis #22133)
  * simplify shl/shr nodes after their resultdef has been set, so the
    resultdef used during simplify is set (fixes same expression as above
    when it is calculated by an inline function)

git-svn-id: trunk@21394 -
2012-05-26 13:31:23 +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
paul
26f66897cd compiler:
- warn if compiler finds implicit or explicit string type conversion from a form of ansi string to a form of unicode string and vice versa
  - mark explicit warnings as OFF by default
  - warn if compiler finds an assignment of an unicode char const to ansi string or char type (warn for assignment of unicode string const to be implemented)
  - revert a piece of code from r19457 regards shortstring handling because shortstring handling should not differ from ansistring in this paticular case

git-svn-id: trunk@19574 -
2011-11-03 00:39:22 +00:00
paul
435b72bcb1 compiler: check left node to be ord const diring widechar/unicodechar to shortstring before executing the code related to tordconstn()
git-svn-id: trunk@19566 -
2011-10-31 07:00:38 +00:00
paul
c1866d5c17 compiler:
- don't pass CP_NONE encoding to internal functions. They handled it as 0 encoding. This will optimize the generated code a bit.
  - convert all king of string/char/pchar constants to local ansistring def if they needs to be passed to rawbytestring type. They should not get a CP_NONE codepage (delphi compatible)
  - don't convert left and right arguments of string concatenation to ansistring type if they are already ansistrings but with different codepage - RTL already handles different codepages in concat routine
  - fix resultdef for ansistring concatenations inside assignments - return def of left assignment operand if it is already ansistring - this reduces amount of unneeded condepage conversions since concat functions can return result in any desired codepage
rtl: remove CP_NONE comparisions from most of RTL functions, replace 0 constant with CP_ACP
tests: add test to check various conversions to RawByteString type

git-svn-id: trunk@19519 -
2011-10-20 09:25:51 +00:00
paul
c6ca9e5091 compiler:
- add helper function getansistringcodepage which returns explicitly set codepage or 0 in other case
  - add helper function getansistringdef which return a def with explicitly set codepage or cansistringtype in other case
  - change tstoreddef.createnai constructor to allow set codepage in constructor
  - don't convert string constants to rawbytestring. if string constant already has a codepage - preserve it or convert to ansistring codepage (delphi compatible)
  - don't perform string conversion from ansistring to strings with explicitly set codepage (by directive or by compiler switch) and vice versa (delphi compatible)
  + test which covers most of the cases

git-svn-id: trunk@19510 -
2011-10-19 02:45:52 +00:00
paul
9bc540e1c2 compiler: cleanup old code
git-svn-id: trunk@19458 -
2011-10-11 03:58:13 +00:00
paul
a99ffb3097 compiler: apply patches from Inoussa and Jonas:
defcmp: Address code paged' string type comparison taking care of the code page
  ncnv: Remove un-needed code page comparison to CP_UTF8, some fixes regarding shortstrings and wide char/string 
  ncon: For the case of tstringconstnode.changestringtype (ncon.pas) where the code page are of CP_NONE or 0 no translation is done as :
    * CP_NONE is compatible to all
    * For 0 the raw bytes are just copied.
 My changes:
  - change ascii2unicode to allow pass source codepage, 
  - convert in both cases when source or destination is UTF8

git-svn-id: trunk@19457 -
2011-10-11 01:21:07 +00:00
paul
e0fecf5332 compiler: revert r19358. As stated by Florian, compiler should be able to compile with the latest RTL.
git-svn-id: trunk@19360 -
2011-10-04 10:12:49 +00:00
paul
ee2e0a0c1d compiler: remove CP_xxx constants since they are present in the system unit now
git-svn-id: trunk@19358 -
2011-10-04 06:03:03 +00:00
paul
7a74d2c2f8 compiler: reduce amount of hints and notes
git-svn-id: trunk@19293 -
2011-09-30 08:56:05 +00:00
paul
5560f6b3f2 compiler + rtl: pass codepage to fpc_CharArray_To_AnsiStr to get the preserve the codepage of result string
git-svn-id: trunk@19240 -
2011-09-26 04:49:09 +00:00
paul
4d3da666db compiler: replace string codepage comparison to numeric. store codepage as number in current settings
git-svn-id: trunk@19144 -
2011-09-19 00:48:43 +00:00
florian
3e7ee21230 * booltype => pasbool8type
git-svn-id: trunk@19129 -
2011-09-17 15:33:49 +00:00
paul
05d66e31ce merge r17603 from cpstrnew branch by inoussa:
Updated to take care of the code page : fpc_char_to_ansistr, fpc_pchar_to_ansistr, fpc_AnsiStr_To_ShortStr

git-svn-id: trunk@19122 -
2011-09-17 14:07:20 +00:00
paul
aaf5392315 merge r17601 from cpstrnew branch by inoussa:
Correct fpc_ansistr_to_ansistr and fpc_short_to_ansistr and test

git-svn-id: trunk@19121 -
2011-09-17 14:03:10 +00:00
paul
723f3424d4 merge r17484 from cpstrnew branch by michael:
* Patch from Inoussa:
* defcmp.pas
    ** ansistring to/from RawByteString are evaluated "te_equal"
    ** ansistring to UTF8string is evaluated (te_convert_l1,tc_string_2_string)

* ncnv.pas
    ** "ttypeconvnode.typecheck_char_to_string" : WideChar to AnsiString/ShortString
        is possible if the source code page is not utf8
    ** "ttypeconvnode.typecheck_char_to_char" : WideChar to AnsiChar
        is possible if the source code page is not utf8

* ncon.pas
    ** "tstringconstnode.changestringtype" : Unicode to utf8string bug fix(set the encoding),
       constants in the source code with code page set utf8 should be converted back to utf8

* nopt.pas
    ** "genmultistringadd" : fpc_<stringname>_concat_multi have a new parameter "cp"
        to indicate the "DestS" code page if the variable content is nil. This is required
        in order not to loose the declared code page.

* pinline.pas
    ** "inline_setlength" : a new parameter "cp" to indicate the code page if the variable content
       is nil. This is required in order not to loose the declared code page.
* ptconst.pas
    ** "parse_arraydef" : for string const to array of ansichar/widechar conversion check for wide string and
        convert if it is required. For char const to array of ansichar/widechar conversion check for wide char and
        convert if it is required.

git-svn-id: trunk@19113 -
2011-09-17 13:30:09 +00:00
paul
1db610ecbd merge r17434 from cpstrnew branch by michael:
* Patch from Inoussa to fix constant strings with codepage

git-svn-id: trunk@19109 -
2011-09-17 13:19:59 +00:00
paul
7fd7eee1c9 merge r17330 from cpstrnew branch by michael:
* Patch from Inoussa, fixing tunistr1.pp and twide1.pp

git-svn-id: trunk@19107 -
2011-09-17 13:12:07 +00:00
paul
29c6b034aa merge r17330 from cpstrnew branch by michael:
* Patch from inoussa to handle pwchararray to ansistr

git-svn-id: trunk@19106 -
2011-09-17 13:07:03 +00:00
paul
fbc01291c4 merge r17327 from cpstrnew branch by michael:
* Patch from Inoussa to fix first test case

git-svn-id: trunk@19105 -
2011-09-17 13:04:50 +00:00
paul
06af8f3e44 merge r13486 from cpstrnew branch by florian:
+ fpc_ansistr_to_ansistr implemented, rtl compiles again

git-svn-id: trunk@19084 -
2011-09-17 11:03:30 +00:00
paul
ae0d732c8f merge r13485 from cpstrnew branch by florian:
* fixed compilation of system unit after last changes

git-svn-id: trunk@19083 -
2011-09-17 11:01:42 +00:00
Jonas Maebe
1403e3df29 * renamed fpc_WChar_To_ShortStr() compilerproc to fpc_UChar_To_ShortStr() for
consistency with other helpers
  + added lowercase(unicodechar) and lowercase(unicodestring) overloads (for some
    reason only upcase() existed for them)

git-svn-id: branches/jvmbackend@18881 -
2011-08-28 19:22:15 +00:00
Jonas Maebe
7da5987d03 * fixed passing single elements to open array var-parameters on non-managed
platforms after r18561 (newly introduced element-to-open-array type
    conversion retains the value location on those platforms)

git-svn-id: branches/jvmbackend@18793 -
2011-08-20 20:37:09 +00:00
Jonas Maebe
28c20cfc5e * the default string type for the JVM target is no longer automatically
unicodestring = java.lang.String. The reason this was the default in
    the past is that this was the first string type that was implemented,
    and without it being the default most code involving string operations
    would fail. Now the default strings types are the same as for other
    targets
  + new {$modeswitch unicodestrings} directive, that when activated
    *together* with {$h+},
   1) changes char into an alias for widechar
   2) changes string into an alias for unicodestring
   3) changes the preferred string evaluation type (in case of uncertainty)
      to unicodestring
    {$modeswitch unicodestrings} with {$h-} does not change anything at all
    regarding the string type (it still changes the char type)
  + new uuchar unit that redefines char as widechar, and which is automatically
    included by the compiler if {$modeswitch unicodestrings} is enabled

git-svn-id: branches/jvmbackend@18781 -
2011-08-20 08:35:47 +00:00
Jonas Maebe
67c2c7c166 * renamed cchartype to cansichartype
git-svn-id: branches/jvmbackend@18779 -
2011-08-20 08:35:24 +00:00
Jonas Maebe
851cb65021 * activate code to remove unnecessary widenings to 64 bit in case
cpu64bitaddr is not defined rather than if cpu64bitalu is not
    defined, because whether or not operations should be 64 bit by
    default depends on cpu64bitaddr, and even if a cpu can perform
    64 bit alu operations, 32 bit ones are likely faster

git-svn-id: branches/jvmbackend@18748 -
2011-08-20 08:32:26 +00:00
Jonas Maebe
d48fa1d7e2 * for all managed VM targets, reject ord->ptr typecasts (except for 0),
typeof(), typeinfo(), seg(), ofs(), settextbuf(), slice(), resourcestring,
    new(), dispose()

git-svn-id: branches/jvmbackend@18747 -
2011-08-20 08:32:21 +00:00
Jonas Maebe
979f55e1db + support for procedural variables for the JVM target
o every porocedural variable type is represented by a class with one
     public "invoke" method whose signature matches the signature of the
     procvar
   o internally, dispatching happens via java.lang.reflect.Method.invoke().
     WARNING: while this allows calling private/protected or other methods
     that are normally not accessible from another context, a security
     manger can override this. If such a security manager is installed,
     most procvars will cause security exceptions
   o such dispatching also requires that all arguments are wrapped, but
     that's done in the compiler-generated body of the invoke method,
     so that procvars can also be called conveniently from Java code
   o typecasting between a procedure of object and tmethod is supported,
     as well as Delphi-style replacing of only the method pointer via
     @procvar1=@procvar2.
   o nested procvars are not yet supported, but most of the basic
     infrastructure for them is already present
  * all units/programs now get an internal __FPC_JVM_Module_Class_Alias$
    type when compiled for the JVM target, which is an "external" class
    that maps to the unit name. This is required to look up the
    JLRMethod instances for regular functions/procedures
  + new tabstractprocdef.copyas() method that allows to create a procvar
    from a procdef and vice versa

git-svn-id: branches/jvmbackend@18690 -
2011-08-20 08:24:58 +00:00
Jonas Maebe
569228447d * converted all enum handling for the JVM target so that it uses the
JDK class-style enums rather than plain ordinals like in Pascal
   o for Pascal code, nothing changes, except that for the JVM target
     you can always typecast any enum into a class instance (to interface
     with the JDK)
   o to Java programs, FPC enums look exactly like Java enum types

git-svn-id: branches/jvmbackend@18620 -
2011-08-20 08:15:54 +00:00
Jonas Maebe
223057f1a7 + support for is/as and Java interfaces
git-svn-id: branches/jvmbackend@18578 -
2011-08-20 08:12:09 +00:00
Jonas Maebe
0706cb5eb6 + support for pointers to types that are implicit pointer types in the JVM
(non-dynamic arrays, records, shortstrings)
  - removed the ability to typecast such types directly into related class
    types, you have to use the @-operator first now to get a pointer to
    the type
   o updated the RTL and internal compiler code to properly use this
     new convention
   o allowed removing several special cases from
     tjvmtypeconvnode.target_specific_general_typeconv(), and that
     method can probably be removed completely over time
  * no longer give compile time errors for pointer-related typecasts that
    will fail at run time, because the checking was too complex and could
    be worked around via actual pointer typecasts anyway
  * removed some unnecessary checkcast operations (for shortstring/
    shortstringclass)

git-svn-id: branches/jvmbackend@18574 -
2011-08-20 08:11:49 +00:00
Jonas Maebe
6857dde33e + shortstring support for the JVM target (including accessing character 0 as
the "length byte")

git-svn-id: branches/jvmbackend@18570 -
2011-08-20 08:11:28 +00:00
Jonas Maebe
446d91eaab + ansistring support. Items of note:
o support for ansistring constants. It's done via a detour because the
      JVM only supports UTF-16 string constants (no array of byte or anything
      like that): store every ansicharacter in the lower 8 bits of an
      UTF-16 constant string, and at run time copy the characters to an
      ansistring. The alternative is to generate code that stores every
      character separately to an array.
    o the base ansistring support is implemented in a class called
      AnsistringClass, and an ansistring is simply an instance of this
      class under the hood
    o the compiler currently does generate nil pointers as empty
      ansistrings unlike for unicodestrings, where we always
      explicitly generate an empty string. The reason is that
      unicodestrings are the same as JLString and hence common
      for Java interoperation, while ansistrings are unlikely to
      be used in interaction with external Java code

  * fixed indentation

git-svn-id: branches/jvmbackend@18562 -
2011-08-20 08:10:39 +00:00
Jonas Maebe
aa1f299a17 + added hook for "individual value to open array of one element"-conversion,
so it can be intercepted by the JVM backend (it has to create an actual
    array)
  + JVM support for the elem_2_open_array hook

git-svn-id: branches/jvmbackend@18561 -
2011-08-20 08:10:31 +00:00
Jonas Maebe
60f8254d63 * don't internalerror when converting to an open array and passing as
var/out parameter (these conversions are replaced by another
    construct on non-JVM targets, so didn't cause a problem there)

git-svn-id: branches/jvmbackend@18555 -
2011-08-20 08:10:00 +00:00
Jonas Maebe
10a7532968 * differentiate between typecasts on the assignment side or not, because we
cannot insert typecasting checks on the assignment side, only on the
    values that are being assigned
   o since valid_for_assignment() is called in tassignmentnode.typecheckpass()
     after typecheckpassing left and right, moved the conversion of the
     typecheck nodes into JVM-specific constructs from typecheckpass to
     pass_1, so that they can use the information whether they are on
     the assignment side or not
  * forbid casting a child type to a parent type on the assignment side on
    managed platforms, because that circumvents the type checking

git-svn-id: branches/jvmbackend@18515 -
2011-08-20 08:06:20 +00:00
Jonas Maebe
c75246706d + stubbed ansistring support (using ansistrings compiles, but does not
generate working code)

git-svn-id: branches/jvmbackend@18499 -
2011-08-20 08:04:57 +00:00
Jonas Maebe
be92f47cc7 * don't simply replace the resultdef of typeconverted nodes if the new
and old def have a different deftype (see added comment why)

git-svn-id: branches/jvmbackend@18492 -
2011-08-20 08:04:21 +00:00
Jonas Maebe
d79160a6af * correctly handle explicit typecasts between records and jlobject/
fpcbaserecordtype for the JVM target (intercept in ncnv via new
    target_specific_general_typeconv helper, handle in as/is code)
  * not only check for related types in htypechk in case they are
    objdefs, but always do so (records are related to jlobject/fpcbaserecord
    on the JVM target)

git-svn-id: branches/jvmbackend@18458 -
2011-08-20 08:01:29 +00:00
Jonas Maebe
b4ffcaf88e * redirect the ttypeconvnode.typecheck* methods just like the firstpass
and code generation pass methods so they can be overridden

git-svn-id: branches/jvmbackend@18423 -
2011-08-20 07:58:25 +00:00
Jonas Maebe
fde622e050 * generate a loadvmtaddrnode wrapper around Java objectdef typenode arguments
to tasnode (like for regular Object Pascal classes)
  * don't collect WPO information for Java classes in tloadvmtaddrnode.pass_1()
    (devirtualization can't work for Java, since classes can always be loaded
     at run time, except for final/sealed classes -- but that's not yet
     implemented)
  + JVM is-node support, unified JVM type checking codegen for is- and as-nodes

git-svn-id: branches/jvmbackend@18383 -
2011-08-20 07:54:57 +00:00
Jonas Maebe
8643ab7905 + hooks for target-specific handling of explicit type conversions and
as-nodes (required for JVM target: bit pattern reinterpretations
    have to be handled via conversion because of type safety reasons,
    and as-nodes will also have to be able to handled class<->dynarray
    checks/conversions)

git-svn-id: branches/jvmbackend@18375 -
2011-08-20 07:53:56 +00:00
Jonas Maebe
48695a7705 * when removing unnecessary 64 bit widenings, modify both the resultdef
and the totypedef of typeconvnodes because the totypedef is used for
    equality comparisons in the node cse

git-svn-id: trunk@18171 -
2011-08-11 16:05:11 +00:00
florian
d35d1ed357 + initial support for pascal booleans with sizes 2, 4 and 8
git-svn-id: branches/pasboolxx@17836 -
2011-06-26 15:02:37 +00:00
marco
90c47c5c86 * fix for renaming of type_interface_noguid (or so) to type_E_interface...
by Florian in r17722

git-svn-id: trunk@17731 -
2011-06-12 13:45:38 +00:00
tom_at_work
1f023f4b36 * Use new qword_to_float32/64 compilerproc functions in first_int_to_real
git-svn-id: trunk@17624 -
2011-06-01 13:27:45 +00:00
paul
901a9a974e compiler: don't create set constants from arrays with high bound > 255 if elements of array are lower than 255
git-svn-id: trunk@17372 -
2011-04-26 00:17:14 +00:00
florian
58fcf9dc52 * probably mark an overloaded := operator used as type conversion as used, resolves #18909
git-svn-id: trunk@17320 -
2011-04-14 21:11:27 +00:00
Jonas Maebe
eab29db98a * merged tasnode.pass_typecheck() and tisnode.pass_typecheck() into a single
tasisnode.pass_typecheck() since they were almost identical (only the
    resultdef of the nodes is different)

git-svn-id: trunk@16846 -
2011-01-30 10:37:21 +00:00
Jonas Maebe
d76ddcabe6 * don't give an internalerror when trying to explicitly apply an invalid
typecast to an array-of-const (mantis #18267)

git-svn-id: trunk@16749 -
2011-01-11 15:47:56 +00:00
sergei
331a72c8d6 * ncnv.pas, insert_varargstypeconv(): Do not cast a string literal to AnsiString if it has been already casted to Wide/UnicodeString, resolves #18266.
git-svn-id: trunk@16593 -
2010-12-19 15:08:42 +00:00
florian
eb3644140a * patches from Aleksa Todorovic for #15480 to improve error reporting, does not resolve #15480
git-svn-id: trunk@16287 -
2010-11-01 20:24:01 +00:00
Jonas Maebe
14b95b3b9b * always force range checking for the upper and lower bounds of for-loops if
they are constants (instead of only on 32 bit systems), and always use the
    actual upper/lower bound of the loop variable instead of hardcoding the
    bounds of longint (mantis #17646)

git-svn-id: trunk@16213 -
2010-10-24 14:55:48 +00:00
Jonas Maebe
769eb3f604 * moved the initialisation of the nodetree and tai class reference constants
from the unit initialisation sections to the variable declaration sections
    to prevent the base units from overriding derived classes (based on patch
    by Hans-Peter Dietrich, mantis #17516)

git-svn-id: trunk@16118 -
2010-10-09 18:52:22 +00:00
Jonas Maebe
94d976bc87 * when simplifying ordinal expressions during inlining, keep the resultdef
that was set during the typecheck pass because typeconversion nodes
    may have been optimised away previously and sometimes the resultdef is
    important (e.g. for the value of callparanodes) (mantis #17458)

git-svn-id: trunk@16101 -
2010-10-07 15:08:52 +00:00
Jonas Maebe
d1206c6279 * also set the persistent typedef of simplified ordconstn type conversions
(related to mantis #17458)

git-svn-id: trunk@16071 -
2010-09-30 20:45:31 +00:00
Jonas Maebe
57bd6d2685 + merged nestedprocvars branch
+ support for nested procedural variables:
    o activate using {$modeswitch nestedprocvars} (compatible with all
      regular syntax modes, enabled by default for MacPas mode)
    o activating this mode switch changes the way the frame pointer is
      passed to nested routines into the same way that Delphi uses (always
      passed via the stack, and if necessary removed from the stack by
      the caller) -- Todo: possibly also allow using this parameter
      passing convention without enabling nested procvars, maybe even
      by default in Delphi mode, see mantis #9432
    o both global and nested routines can be passed to/assigned to a
      nested procvar (and called via them). Note that converting global
      *procvars* to nested procvars is intentionally not supported, so
      that this functionality can also be implemented via compile-time
      generated trampolines if necessary (e.g. for LLVM or CIL backends
      as long as they don't support the aforementioned parameter passing
      convention)
    o a nested procvar can both be declared using a Mac/ISO Pascal style
      "inline" type declaration as a parameter type, or as a stand-alone
      type (in the latter case, add "is nested" at the end in analogy to
      "of object" for method pointers -- note that using variables of
      such a type is dangerous, because if you call them once the enclosing
      stack frame no longer exists on the stack, the results are
      undefined; this is however allowed for Metaware Pascal compatibility)

git-svn-id: trunk@15694 -
2010-08-02 22:20:36 +00:00
ivost
17260e1119 * reimplemented IS operator, it supports now
object is interface
	object is corbaintf
	interface is interface
	interface is class
	object is class

git-svn-id: trunk@15434 -
2010-06-13 22:04:35 +00:00
Jonas Maebe
40705a085f * renamed is_refcounted_type() into is_managed_type(), because it also
returns true for variants and those aren't refcounted
  * also allow tempnodes for pointers to managed types to be put in
    registers (not sure why it was disabled, and there are no
    testsuite regressions by enabling it)

git-svn-id: trunk@15319 -
2010-05-22 20:51:50 +00:00
florian
d0e9a7ead9 + description of tasnode.call (by Jonas Maebe)
git-svn-id: trunk@15198 -
2010-04-28 21:35:19 +00:00
ivost
dc785f6f68 * implemented intf as object. When doing IInterface as TObject the compiler calls fpc_intf_as_class to query for the IImplementorGetter interface and then invokes GetObject to get the
objects reference.
* by default the TInterfacedObject is supporting now IImplementorGetter

git-svn-id: trunk@15080 -
2010-03-28 00:17:20 +00:00
Jonas Maebe
0cfc6e1cac + support for "univ" in macpas mode: a parameter modifier that allows
passing any value to that parameter which has the same size as the
    parameter (it basically acts as if there is an explicit type conversion
    to the parameter type around the value at the caller side). If a procvar
    has an univ parameter, all procvars whose corresponding parameter
    has the same size as that univ parameter are similarly compatible.

    This transparent compatibility can however cause crashes in case of
    of the procvars when one of the types is passed on the stack and the
    other isn't (because then the called routine will a) load the parameter
    from a wrong location and b) pop the wrong amount off of the stack at
    then end). Therefore FPC will warn in most cases where this can happen.
    (mantis #15777)

git-svn-id: trunk@15010 -
2010-03-13 22:13:20 +00:00
Jonas Maebe
cda17ad02a * correctly set the expectloc for int_2_int type conversions of bitpacked
arrays (and some other, related constructs) (mantis #15789)

git-svn-id: trunk@14927 -
2010-02-19 17:12:47 +00:00
Jonas Maebe
650ba6d50f * an int2int type conversion doesn't retain the value location in
case of a bitpacked access

git-svn-id: trunk@14911 -
2010-02-13 20:56:02 +00:00
Jonas Maebe
85984c2d8f * insert proper type conversions when optimising logical operations and
compares by avoiding unnecessary sign extensions (fixes bug reported in
    http://lists.freepascal.org/lists/fpc-pascal/2010-January/023907.html )
  * never throw away int2int type conversions on bitpacked loads, because
    in these cases the proper bits still need to be selected

git-svn-id: trunk@14892 -
2010-02-12 18:13:08 +00:00
Jonas Maebe
6b0a0c149b * don't perform a range check in Delphi mode when passing a cardinal as
vtInteger to an array-of-const parameter (mantis #15727)

git-svn-id: trunk@14882 -
2010-02-10 16:35:37 +00:00
florian
f12ba2ed23 * fixes ttypeconvnode.docompare hopefully finally (nobody has seen my last attempt ;))
git-svn-id: trunk@14755 -
2010-01-20 22:07:54 +00:00
florian
3c7f726f98 * typeconvnodes are only equal if also their result type is equal
git-svn-id: trunk@14690 -
2010-01-17 10:07:44 +00:00
paul
74cc1e0bab compiler: allow 'as' for dispinterface, allow comparisons of dispinterface and pointers (issue #0015530, issue #0015529)
git-svn-id: trunk@14663 -
2010-01-16 11:37:25 +00:00
florian
c1f3d8dcaa * unified names of system_*/systems_* sets
git-svn-id: trunk@14566 -
2010-01-07 18:16:20 +00:00
Jonas Maebe
b4c572483b * always call procvars inside varargs in TP/Delphi mode (mantis #15446)
git-svn-id: trunk@14527 -
2010-01-02 21:43:19 +00:00
florian
dab642986e * patch by Sergei Gorelkin, fixes several issues with implements, resolves #15209
git-svn-id: trunk@14466 -
2009-12-23 16:23:19 +00:00
Jonas Maebe
dd7e472fa4 * don't convert "cardinal div (cardinal-cardinal)" to longint after it
has been upcasted to int64, but convert it back to cardinal (mantis
    #15015)
  * put the "remove unnecessary 64 bit type conversions" code between
    {$ifndef cpu64bitalu} instead of {$ifndef cpu64bitaddr}

git-svn-id: trunk@14396 -
2009-12-10 21:08:31 +00:00
Jonas Maebe
b9b95a8f73 * fixed compiler crash when putting non-constant string in a set expression
(mantis #15288)

git-svn-id: trunk@14367 -
2009-12-08 17:15:31 +00:00
Jonas Maebe
d1538ab023 o added ARM VPFv2/VFPv3 support:
+ RTL support:
      o VFP exceptions are disabled by default on Darwin,
        because they cause kernel panics on iPhoneOS 2.2.1 at least
      o all denormals are truncated to 0 on Darwin, because disabling
        that also causes kernel panics on iPhoneOS 2.2.1 (probably
        because otherwise denormals can also cause exceptions)
    * set softfloat rounding mode correctly for non-wince/darwin/vfp
      targets
    + compiler support: only half the number of single precision
      registers is available due to limitations of the register
      allocator
    + added a number of comments about why the stackframe on ARM is
      set up the way it is by the compiler
    + added regtype and subregtype info to regsets, because they're
      also used for VFP registers (+ support in assembler reader)
    + various generic support routines for dealing with floating point
      values located in integer registers that have to be transferred to
      mm registers (needed for VFP)
    * renamed use_sse() to use_vectorfpu() and also use it for
      ARM/vfp support
    o only superficially tested for Linux (compiler compiled with -Cpvfpv6
      -Cfvfpv2 works on a Cortex-A8, no testsuite run performed -- at least
      the fpu exception handler still needs to be implemented), Darwin has
      been tested more thoroughly
  + added ARMv6 cpu type and made it default for Darwin/ARM
  + ARMv6+ implementations of atomic operations using ldrex/strex
  * don't use r9 on Darwin/ARM, as it's reserved under certain
    circumstances (don't know yet which ones)
  * changed C-test object files for ARM/Darwin to ARMv6 versions
  * check in assembler reader that regsets are not empty, because
    instructions with a regset operand have undefined behaviour in that
    case
  * fixed resultdef of tarmtypeconvnode.first_int_to_real in case of
    int64->single type conversion
  * fixed constant pool locations in case 64 bit constants are generated,
    and/or when vfp instructions with limited reach are present

  WARNING: when using VFP on an ARMv6 or later cpu, you *must* compile all
    code with -Cparmv6 (or higher), or you will get crashes. The reason is
    that storing/restoring multiple VFP registers must happen using
    different instructions on pre/post-ARMv6.

git-svn-id: trunk@14317 -
2009-12-03 22:46:30 +00:00
Jonas Maebe
559e284bd0 * merged r13762-14047 from trunk
git-svn-id: branches/objc@14048 -
2009-11-04 15:50:26 +00:00
Jonas Maebe
fffa66e2f9 * only allow implicit conversions from 0 to NIL in Delphi mode, rather than
from any ordinal constant, and give a warning for this one allowed
    conversion like Kylix does (mantis #14713)
  * this required calling simplify from typecheckpass in ttypeconvnode for
    cord_to_pointer, because this simplification prevents the type checking
    from happening (but the typecheck itself also does that simplification)

git-svn-id: trunk@13919 -
2009-10-22 19:49:08 +00:00
Jonas Maebe
a149674a75 Merged revisions 13458-13596 via svnmerge from
svn+ssh://jonas@svn.freepascal.org/FPC/svn/fpc/trunk

git-svn-id: branches/objc@13598 -
2009-08-25 19:47:36 +00:00
Jonas Maebe
106c0673c0 * allow passing records to C varargs (also allowed by C)
git-svn-id: trunk@13595 -
2009-08-25 19:04:34 +00:00
Jonas Maebe
2f7457f37e * set the fileinfo of typeconversions created using inserttypeconv*()
to that of the left node
  * same for a typeconversion inserted in the typecheck pass of
    taddrnode

git-svn-id: trunk@13579 -
2009-08-22 22:11:03 +00:00
Jonas Maebe
acdb0bbb3e * don't change current_filepos in pass_typecheck when not generating
errornodes (so the that the parser won't afterwards suddenly start
    creating nodes with this different fileinfo)

git-svn-id: trunk@13577 -
2009-08-22 20:21:56 +00:00
Jonas Maebe
a25e791ff8 * allow Objective-C classes/protocols in C varargs parameter lists
git-svn-id: branches/objc@13460 -
2009-07-26 16:00:33 +00:00
Jonas Maebe
335e159c11 Merged revisions 13351-13373,13376-13457 via svnmerge from
svn+ssh://jonas@svn.freepascal.org/FPC/svn/fpc/trunk

git-svn-id: branches/objc@13458 -
2009-07-26 14:31:50 +00:00
Jonas Maebe
754696d1f5 * enable converting procedure callnodes with only default parameters into
procvars in tp/delphi mode (mantis #11771)

git-svn-id: trunk@13400 -
2009-07-17 10:29:56 +00:00
Jonas Maebe
5a2ccfff52 --WARNING: start build process with FPC 2.2.4; won't work when
starting with a previous 2.3.1 or compiler built from the objc branch
  + added basic objcprotocol support (only for external protocols
    currently)
     o use in type declaration: "type xp = objcprotocol ... end;"
     o when defining a root class that implements it:
       "type yc = objcclass(xp) ... end" (note: no support yet
       for something like "objcclass(id,xp)" or so)
     o when defining a non-root class that implements a protocol:
       "type zc = objcclass(nsobject,xp) ... end"
     o includes support for "required" and "optional" sections
     o no support yet for the objcprotocol(<protocol>) expression
       that enables getting a class instance representing the
       protocol (e.g., for use with "conformsToProtocol:")
     o message names have to specified in protocol declarations,
       but if an objcclass implements a protocol, the message names do
       not have to be repeated (but if they are, they have to match;
       the same goes when overriding inherited methods)
  + allow specifying the external name of Objective-C classes and
    protocols, since classes and protocols can have the same name
    (and you cannot use the same Pascal identifier in such caseq)
  + added NSObject protocol, and make the NSObject class use it
  + added missing NSObject class methods that have the same name
    as instance methods (added "class" name prefix to avoid clashes)
  * fixed several cases where the compiler did not treat Objective-C
    classes/protocols the same as Object Pascal classes/interfaces
    (a.o., forward declarations, alignment, regvars, several type
     conversions, ...)
  * allow "override" directive in objcclass declarations, and print
    a hint if it's forgotten in an external declaration (because it
    doesn't really matter there, and may make automated header
    conversion harder than necessary) and an error if will be used in
    a non-external declaration (because it is not possible to start
    a new vmt entry-tree in Objective-C, you can only override parent
    methods)
  * reject objcclasses/protocols as parameters to typeof()
  * don't try to test VMT validity of objcclasses/protocols

git-svn-id: branches/objc@13375 -
2009-07-09 20:48:28 +00:00
Jonas Maebe
1f6ec379de * moved field definitions before method/property definitions (see mantis
#13971)

git-svn-id: trunk@13330 -
2009-06-27 11:27:31 +00:00
Jonas Maebe
66c14c8a88 * don't mark classes used in "is"- or "as"-expressions as potentially
instantiated (for wpo)
  * also replace vmt-entries for classes for which we don't have any
    information at all with FPC_ABSTRACTERROR (since that means they
    certainly are not instantiated), except for their published and
    virtual class methods
  * fixed check for published methods in wpo

git-svn-id: trunk@13219 -
2009-05-31 13:52:40 +00:00
Jonas Maebe
966ebbf157 * fixed missing reference counting in case a refcounted type was implicitly
type casted to a non-refcounted type, e.g. dynarray to pointer in Delphi
    mode (mantis #13820)

git-svn-id: trunk@13195 -
2009-05-25 19:41:14 +00:00
ivost
0438667eed * fixed bug #5800
* const s: string = icorbainterface; is possible now
* as operator is working now with corba interfaces
* supports helper function is working now with corba interfaces

git-svn-id: trunk@12729 -
2009-02-09 00:35:09 +00:00
Jonas Maebe
9d81148986 * only convert character constants into widechar/widestring when assigned
to a widechar/widestring (compatible with constant string handling,
    mantis #13036)

git-svn-id: trunk@12588 -
2009-01-24 12:45:03 +00:00
Jonas Maebe
bfbfa2eb64 * when converting a constant char (not widechar) with ord>=128 to a string,
convert it into a widechar at compile time using the current source file's
    code page (and in case it was to a non-widestring, then convert it at run
    time into the current run time ansi code page) (mantis #12993)

    Previously, the characters were either stuffed into the string without
    conversion (widestring), or passed to the run time "ansi-character to
    stringtype" routine (other string types; which was also wrong, since
    that routine expects the character to be in ansi-encoding, which is
    not necessarily the same as whatever the source file encoding was)

git-svn-id: trunk@12580 -
2009-01-21 18:58:37 +00:00
Jonas Maebe
7b4eed79ce * fixed generic uint32->float softfpu conversion
git-svn-id: trunk@12200 -
2008-11-22 18:05:19 +00:00
florian
a0939ad9d6 * actually the important part of r12120 containing the compiler change
git-svn-id: trunk@12121 -
2008-11-16 14:08:31 +00:00
Jonas Maebe
c6c9ec83e0 * only make the target of a type conversion not regable after checking
whether it's assignable if 1) the size/sign changes (was already the
    case) and 2) in case something actually can be assigned to it

git-svn-id: trunk@12039 -
2008-11-09 10:24:23 +00:00
Jonas Maebe
1e178d324f * explicitly check whether the methodpointer isn't the same as the result
before optimising function result assignment, because at this point the
    hidden self parameter is not yet inserted (mantis #12597)
  * changed ttypeconvnode.actualtargetnode to use the same logic as what
    is used to determine whether something can be assigned to the result
    of a type conversion (so the above check also works if the methodpointer
    contains a typecast to a different object type)

git-svn-id: trunk@12038 -
2008-11-09 10:19:29 +00:00
Jonas Maebe
19f8aede99 + some missing docompare() overrides
git-svn-id: trunk@11937 -
2008-10-19 16:50:43 +00:00
florian
cd6b57c733 * fixed constant char to unicodestring conversion
git-svn-id: trunk@11779 -
2008-09-14 17:19:20 +00:00
florian
b178b08ba7 Merged revisions 11665-11738 via svnmerge from
http://svn.freepascal.org/svn/fpc/branches/unicodestring

........
  r11665 | florian | 2008-08-30 13:30:17 +0200 (Sat, 30 Aug 2008) | 1 line
  
  * continued to work on unicodestring type support
........
  r11666 | florian | 2008-08-30 19:02:26 +0200 (Sat, 30 Aug 2008) | 2 lines
  
  * expectloc for wide/ansi/unicode strings is LOC_CONSTANT or LOC_REGISTER now
........
  r11667 | florian | 2008-08-30 20:42:37 +0200 (Sat, 30 Aug 2008) | 1 line
  
  * more unicodestring stuff fixed, test results on win32 are already good
........
  r11670 | florian | 2008-08-30 23:21:48 +0200 (Sat, 30 Aug 2008) | 2 lines
  
  * first fixes for unix bootstrapping
........
  r11683 | ivost | 2008-09-01 12:46:39 +0200 (Mon, 01 Sep 2008) | 2 lines
  
      * fixed 64bit bug in iconvenc.pas
........
  r11689 | florian | 2008-09-01 23:12:34 +0200 (Mon, 01 Sep 2008) | 1 line
  
  * fixed several errors when building on unix
........
  r11694 | florian | 2008-09-03 20:32:43 +0200 (Wed, 03 Sep 2008) | 1 line
  
  * fixed unix compilation
........
  r11695 | florian | 2008-09-03 21:01:04 +0200 (Wed, 03 Sep 2008) | 1 line
  
  * bootstrapping fix
........
  r11696 | florian | 2008-09-03 21:07:18 +0200 (Wed, 03 Sep 2008) | 1 line
  
  * more bootstrapping fixed
........
  r11698 | florian | 2008-09-03 22:47:54 +0200 (Wed, 03 Sep 2008) | 1 line
  
  + two missing compiler procs exported
........
  r11701 | florian | 2008-09-04 16:42:34 +0200 (Thu, 04 Sep 2008) | 2 lines
  
  + lazarus project for the linux rtl
........
  r11702 | florian | 2008-09-04 16:43:27 +0200 (Thu, 04 Sep 2008) | 2 lines
  
  + set unicode string procedures
........
  r11707 | florian | 2008-09-04 23:23:02 +0200 (Thu, 04 Sep 2008) | 2 lines
  
  * fixed several type casting stuff
........
  r11712 | florian | 2008-09-05 22:46:03 +0200 (Fri, 05 Sep 2008) | 1 line
  
  * fixed unicodestring compilation on windows after recent unix changes
........
  r11713 | florian | 2008-09-05 23:35:12 +0200 (Fri, 05 Sep 2008) | 1 line
  
  + UnicodeString support for Variants
........
  r11715 | florian | 2008-09-06 20:59:54 +0200 (Sat, 06 Sep 2008) | 1 line
  
  * patch by Martin Schreiber for UnicodeString streaming
........
  r11716 | florian | 2008-09-06 22:22:55 +0200 (Sat, 06 Sep 2008) | 2 lines
  
  * fixed test
........
  r11717 | florian | 2008-09-07 10:25:51 +0200 (Sun, 07 Sep 2008) | 1 line
  
  * fixed typo when converting tunicodestring to punicodechar
........
  r11718 | florian | 2008-09-07 11:29:52 +0200 (Sun, 07 Sep 2008) | 3 lines
  
  * fixed writing of UnicodeString properties
  * moved some helper routines to unicode headers
........
  r11734 | florian | 2008-09-09 22:38:55 +0200 (Tue, 09 Sep 2008) | 1 line
  
  * fixed bootstrapping
........
  r11735 | florian | 2008-09-10 11:25:28 +0200 (Wed, 10 Sep 2008) | 2 lines
  
  * first fixes for persisten unicodestrings
........
  r11736 | florian | 2008-09-10 14:31:00 +0200 (Wed, 10 Sep 2008) | 3 lines
  
  Initialized merge tracking via "svnmerge" with revisions "1-11663" from 
  http://svn.freepascal.org/svn/fpc/trunk
........
  r11737 | florian | 2008-09-10 21:06:57 +0200 (Wed, 10 Sep 2008) | 3 lines
  
  * fixed unicodestring <-> variant handling
  * fixed unicodestring property reading
........

git-svn-id: trunk@11739 -
2008-09-10 20:14:31 +00:00
florian
9a83b1d275 * split typecast_string_to_string into simplify and firstpass, allows better constant propagation when inlining, resolves #11327
git-svn-id: trunk@11636 -
2008-08-23 07:29:30 +00:00
florian
1fa70f7a0a * proper support for tobject.getinterface with raw/corba interfaces, resolves #6798 and #6036
git-svn-id: trunk@11497 -
2008-08-01 15:27:58 +00:00
yury
491f0fa1d8 * Replaced all user defined warnings by TODO comments to reduce compiler noise.
git-svn-id: trunk@11443 -
2008-07-23 11:00:03 +00:00
yury
6daceb38f6 * Fixed unreachable code warnings.
git-svn-id: trunk@11440 -
2008-07-23 09:55:44 +00:00
yury
b70bf05ad5 * I hope it's proper fix for r10688.
git-svn-id: trunk@10690 -
2008-04-18 10:51:56 +00:00
Jonas Maebe
62e66d2a56 * explicit typecasting of any ordinal type to a boolean of the same
size must happen without any mangling of the value (mantis #11027)
  * moved checking for signed-to-unsigned (or vice versa) type
    conversions in assignments from htypechk to ncnv (where there
    was already code for similar checks) and added support for
    bool_to_bool there as well

git-svn-id: trunk@10521 -
2008-03-21 14:44:58 +00:00
peter
8f239d04b6 * cleanup and simplify the set type handling
git-svn-id: trunk@10432 -
2008-03-02 17:48:27 +00:00
peter
85e904cb36 * fix range error
git-svn-id: trunk@10424 -
2008-03-02 14:00:38 +00:00
micha
83b7f81f81 + add no-fpu support to compiler/rtl for powerpc-linux (-Cfnone)
git-svn-id: trunk@10422 -
2008-03-02 12:59:02 +00:00
Jonas Maebe
97f4c0a130 * call taddnode.simplify at the very end of taddnode.pass_typecheck, so
it doesn't have to duplicate any type checking code, and so constant
    expressions get the same resultdefs as non-constant expressions
  * properly fixed resultdef determination of "set + setelementn" (follows
    same rules now as "set + set")
  * also convert "longint or/xor cardinal" to int64 (needed for correct
    results with negative numbers and Delphi-compatible) + test
  * extended 64-to-32 type conversion simplification to also handle
    or/xor nodes (so if the result is typecasted back to 32 bit, the
    evaluation can still be done entirely in 32 bit). These changes also
    enable that optimization in some extra cases (not just anymore for
    expressions containing only uint32)

git-svn-id: trunk@10418 -
2008-03-01 20:48:50 +00:00
Jonas Maebe
a2beae0e11 * use more generic set type boundaries for constant sets with one
element in Delphi mode (fixes mantis #10890, but requires more
    thorough changes in nadd.pas for proper fixing)

git-svn-id: trunk@10399 -
2008-02-27 21:17:13 +00:00
Jonas Maebe
179b840cea * also adjust constsetlo when parsing a constant set in Delphi mode
git-svn-id: trunk@10395 -
2008-02-27 15:42:49 +00:00
florian
6c53785e3a * first part of implements clean up and fixing
git-svn-id: trunk@10382 -
2008-02-24 11:05:46 +00:00
Jonas Maebe
f36e5411af * split cpu64bit compiler define into
a) cpu64bitaddr, which means that we are generating a compiler which
       will generate code for targets with a 64 bit address space/abi
    b) cpu64bitalu, which means that we are generating a compiler which
       will generate code for a cpu with support for 64 bit integer
       operations (possibly running in a 32 bit address space, depending
       on the cpu64bitaddr define)
   All cpus which had cpu64bit set now have both the above defines set,
   and none of the 32 bit cpus have cpu64bitalu set (and none will
   compile with it currently)
  + pint and puint types, similar to aint/aword (not pword because that
    that conflicts with pword=^word)
  * several changes from aint/aword to pint/pword
  * some changes of tcgsize2size[OS_INT] to sizeof(pint)

git-svn-id: trunk@10320 -
2008-02-13 20:44:00 +00:00
peter
519b11dba7 * workaround for 2.2 rnagecheck
git-svn-id: trunk@10106 -
2008-01-29 23:19:24 +00:00
Jonas Maebe
8349cde7db * changed byte/word/longbool to be Delphi-compatible (+ similar changes
for qwordbool) + test:
    o assigning true to such a variable now sets them to $ff/$ffff/$ffffffff
    o these types are now all signed
    o converting an integer type to a byte/word/long/qwordbool using an
      explicit type cast keeps the integer's original value stored in the
      bool, instead of forcing it to ord(true)/ord(false)
    (mantis #10233 and #10613, implemented for all architectures, testsuite
     tested for ppc32, sparc and x86)
  * fixed some places where the rtl depended on longbool(true) having the
    value 1
  * extended several boolean tests (and adapted some to no longer assume
    that byte/word/long/qwordbool(true)=1)
  + support for converting to qwordbool in second_int_to_bool for x86, ppc
    and sparc

git-svn-id: trunk@9898 -
2008-01-24 21:30:55 +00:00
Jonas Maebe
84159b3cbb * optimize away unnecessary implicit upcasts to int64 for subtractions
of u32bit values on 32 bit platforms (after the int64 values have 
    already been used for overload selection etc, i.e., semantically
    nothing changes)
  + test which checks that not too many typecasts are optimized away

git-svn-id: trunk@9664 -
2008-01-06 23:30:19 +00:00
florian
8f17101039 * allow application of as operator only to interfaces having a guid, resolves #6797
git-svn-id: trunk@9436 -
2007-12-12 21:07:47 +00:00
Jonas Maebe
742ff35c48 + also optimize assignments from calls to by-reference "results":
o it's a by-reference parameter, but ignore that since it's
      guaranteed to be safe because of the escape analysis
    o it's wrapped in an absolute type conversion -> added
      actualtargetnode method to tnode which digs through that

git-svn-id: trunk@9412 -
2007-12-07 17:58:25 +00:00
yury
4e3547c7bf * Improved warning "Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.":
- check for procedure and class pointers as well;
  - do not warn if typecasted pointer is passed as parameter or directly assigned to a variable. 

git-svn-id: trunk@9264 -
2007-11-16 13:52:19 +00:00
Jonas Maebe
70c0c2ddd9 * all currently supported platforms require that single precision
parameters passed as C-style varargs are upgraded to double
    precision

git-svn-id: trunk@9201 -
2007-11-11 18:01:29 +00:00
Jonas Maebe
e716ac6b6b * give ord->formaldef again a higher precedence than ord->floatdef
(last convert level that is added, needs a more structural
     solution)

git-svn-id: trunk@9057 -
2007-11-02 11:17:11 +00:00
Jonas Maebe
82a0749970 * prefer non-matching orddef conversions to orddef-to-pointer conversions
(mantis #10002) and also to orddef-to-real conversions
    (delphi-compatible). More tests and fixes will follow later.

git-svn-id: trunk@9015 -
2007-10-31 17:20:37 +00:00
Jonas Maebe
0aba0acdf6 * fixed widechar to shortstring conversion after r8898 (webtbs/tw7758)
git-svn-id: trunk@8908 -
2007-10-21 22:58:17 +00:00
florian
7878f0feb3 * made all fpc_*_to_shortstr helpers a procedure, resolves #8580
git-svn-id: trunk@8898 -
2007-10-21 17:33:18 +00:00
peter
6b8aed593f * remove registers{int/mmx/fpu} from firstpass
* small cleanups of unused variables in firstpass
  * node_resources_fpu() created to get an approximation of the
    required fpu registers
  * for the moment use node_complexity in the CG until the
    node_resource_int() is created

git-svn-id: trunk@8655 -
2007-09-26 21:12:01 +00:00
peter
e0cf015159 * refactor function result handling
* rename methodpointerinit/done to callinitblock/callcleanupblock
  * moved checks in callnode to separate functions
  * funcretnode is now always a simple node instead of a block of
    statements
  * funcret and methodpointer are generated/optimized only in pass_1 so
    a conversion from calln to loadn is much easier
  * function result assignments are much more often optimized to use the
    assignment destination location instead of using a temp

git-svn-id: trunk@8558 -
2007-09-18 22:12:07 +00:00
Jonas Maebe
0040eecf9f + support for extra packing of sets whose lower element number
is <> 0 (Delphi compatible now, + various tests)
  + support for enums and sets in is_in_limit()
  * fixed converting smallset expressions to varsets
  * improved choosing an appropriate common set type when mixing
    set types in an expression
  - removed no longer used normalset code from nadd.pas
  - disabled large set (>256 elements) support for now, because
    they are not yet supported entirely throughout the compiler
    and this causes errors at run time in several situations

git-svn-id: trunk@8515 -
2007-09-16 20:04:45 +00:00
florian
0a50052802 * allow <const. node> -> <struct. type> type casts for internal type cast nodes, this is required by the softfloat code generator, it was forbidden by rev. 8369
git-svn-id: trunk@8504 -
2007-09-16 11:53:05 +00:00
Jonas Maebe
e1aefdbac5 * Improved escape analysis so the improved tretopt no longer fails.
The downside is that because it is context-insensitive, several
    (correct) optimizations which were performed in the past no longer
    are now (and while some new ones are done now, the downside is bigger
    -- but at least the code should be correct in all cases now)

git-svn-id: trunk@8385 -
2007-09-05 13:29:22 +00:00
Jonas Maebe
1ee8207ffa * fixed mantis #9522: no longer allow typecasting ordinal constants
to complex types (caused a lot of internal errors later on, and
    was also Delphi-incompatible)

git-svn-id: trunk@8369 -
2007-09-03 15:55:26 +00:00
Jonas Maebe
30e618ccb6 * fixed typecast error in last char/widechar/widestring patch
git-svn-id: trunk@8358 -
2007-09-02 20:29:26 +00:00
Jonas Maebe
eddc507a13 * disallow widechar sets (Delphi 7 compatible, and were handled wrongly
by FPC previously)
  * tbs/tb0474 now fails -> renamed to tbf/tb0201 (+ new test tbf/tb0202)

git-svn-id: trunk@8284 -
2007-08-14 14:27:59 +00:00
Jonas Maebe
d73e79f163 * fixed regression of webtbs/tw4254: if a constant (wide)string can't be
converted to a pchar at compile time, remove the cstring_to_pchar node
    because it expects a stringconstn in pass_generate_code

git-svn-id: trunk@8275 -
2007-08-13 09:13:07 +00:00