Commit Graph

164 Commits

Author SHA1 Message Date
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
Jonas Maebe
19fb48dfa9 * prefer "any array" -> "open array" over "single element" -> "open array"
conversions, instead failing to choose the best overload (Delphi-compatible)

git-svn-id: trunk@17800 -
2011-06-22 19:32:28 +00:00
florian
37b8b791d5 * overloaded versions of IsNan, resolves #14351
* prefer <ord> -> single over <ord> -> double/extended, this is delphi compatible

git-svn-id: trunk@17758 -
2011-06-14 20:38:51 +00:00
florian
ff6ab60508 * prefer typecast currency->extended over currency->single/double because the former loses no precision while the latter might cause a loss of precision, resolves #19077
git-svn-id: trunk@17297 -
2011-04-10 19:40:18 +00:00
Jonas Maebe
5c2050e756 * when two objectdefs resolve to the same "real" objectdef, consider them
as te_exact rather than as te_equal (otherwise you get compilation errors
    if only a formal external definition is in scope in the interface, but
    the full definition is in scope in the implementation)

git-svn-id: trunk@17201 -
2011-03-28 18:03:57 +00:00
sergei
4780278e7b Fix Mantis #11783:
* Dispinterfaces can be assigned/typecasted to Variants and vice-versa.
  * At the same time, disabled corbainterface assignment compatibility with Variants. Simply intermixing COM and CORBA interfaces is wrong since it causes reference counting calls on CORBA interfaces.
* Dispinterfaces are returned in parameter, similar to regular interfaces.
* Fixed crash in comobj.pp due to incorrect typecast.
* Fixed incorrect dispinterface declarations in the test itself. Now it compiles and works (if MS Excel is installed).

git-svn-id: trunk@16835 -
2011-01-29 13:18:34 +00:00
paul
0c9b40acb7 compiler: record operators
- allow operator also if return type match the structure type (before at least one parameter had to match)
  - search both operands symbol tables for a suitable assignment operator
  - test
based on patch of Blaise Thorn (issue #0018490)

git-svn-id: trunk@16762 -
2011-01-14 02:25:48 +00:00
paul
dad8313512 compiler: handle dispinterfaces the same way as com interfaces because they are IDispatch descendants: increment/decrement they references in assignments and parameters passing by _AddRef, _Release
git-svn-id: trunk@16755 -
2011-01-13 03:38:45 +00:00
Jonas Maebe
2222f2c44b * renamed is_class_or_interface_or_dispinterface_or_objc() into
is_implicit_pointer_object_type() to better indicate the purpose of
    that routine, and to avoid having to change its name every time
    a new object type with this property is added

git-svn-id: trunk@16664 -
2010-12-30 15:19:54 +00:00
paul
66b128efb3 compiler: map delphi Implicit operator to := operator of FPC, add Explicit operator for delphi only (for now) which works when explicit type conversion happens + extend test
git-svn-id: trunk@16636 -
2010-12-25 11:08:02 +00:00
Jonas Maebe
c8115921f1 * fixed comment typo
git-svn-id: trunk@16618 -
2010-12-23 15:14:30 +00:00
florian
e4ecee317e * finer grained convert levels for strings, prefers widestring<->unicodestring over other conversions, resolves #18075
git-svn-id: trunk@16460 -
2010-11-28 10:05:09 +00:00
Jonas Maebe
edfb31c020 * when looking for overloaded conversion (assignment) operators, only ignore
those for variants. All defined operators are guaranteed to be valid by
    the code that checks them when they are defined (mantis #17846)

git-svn-id: trunk@16449 -
2010-11-26 15:37:31 +00:00
joost
07bf44517c * Merged XPCom branch into trunk, added support for constref and changed
the IInterface implementation to be XPCom-compatible
--- Merging r15997 through r16179 into '.':
U    rtl/inc/variants.pp
U    rtl/inc/objpash.inc
U    rtl/inc/objpas.inc
U    rtl/objpas/classes/persist.inc
U    rtl/objpas/classes/compon.inc
U    rtl/objpas/classes/classesh.inc
A    tests/test/tconstref1.pp
A    tests/test/tconstref2.pp
A    tests/test/tconstref3.pp
U    tests/test/tinterface4.pp
A    tests/test/tconstref4.pp
U    tests/webtbs/tw10897.pp
U    tests/webtbs/tw4086.pp
U    tests/webtbs/tw15363.pp
U    tests/webtbs/tw2177.pp
U    tests/webtbs/tw16592.pp
U    tests/tbs/tb0546.pp
U    compiler/sparc/cpupara.pas
U    compiler/i386/cpupara.pas
U    compiler/pdecsub.pas
U    compiler/symdef.pas
U    compiler/powerpc/cpupara.pas
U    compiler/avr/cpupara.pas
U    compiler/browcol.pas
U    compiler/defcmp.pas
U    compiler/powerpc64/cpupara.pas
U    compiler/ncgrtti.pas
U    compiler/x86_64/cpupara.pas
U    compiler/opttail.pas
U    compiler/htypechk.pas
U    compiler/tokens.pas
U    compiler/objcutil.pas
U    compiler/ncal.pas
U    compiler/symtable.pas
U    compiler/symsym.pas
U    compiler/m68k/cpupara.pas
U    compiler/regvars.pas
U    compiler/arm/cpupara.pas
U    compiler/symconst.pas
U    compiler/mips/cpupara.pas
U    compiler/paramgr.pas
U    compiler/psub.pas
U    compiler/pdecvar.pas
U    compiler/dbgstabs.pas
U    compiler/options.pas
U    packages/fcl-fpcunit/src/testutils.pp

git-svn-id: trunk@16180 -
2010-10-17 20:58:22 +00:00
Jonas Maebe
1c9fed7ae3 * resolve anonymous external objcclass definitions to the real type also when
a) defining a child class
     b) checking for type conversion compatibility

git-svn-id: trunk@16013 -
2010-09-19 16:05:32 +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
Jonas Maebe
790c7954b7 * fixed assigning "id" to a protocol instance and using protocol instances
to call methods + test

git-svn-id: trunk@15453 -
2010-06-19 16:19:13 +00:00
paul
1b614b526a compiler:
- add own symbol table for enumeration to store enumeration elements
  - reimplement enumeration member traverse using symbol table instead of firstenum/nextenum - that members are removed
  - implement TEnum.Element access syntax - element is searched in the enumeration symtable in this case instead of global/local symtables
  - implement {$SCOPEDENUM ON/OFF} local switch
  + tests

git-svn-id: trunk@15051 -
2010-03-25 05:46:53 +00:00
paul
49d94c5a16 compiler: implement {$VARPROPSETTER ON/OFF} support which is required for COM (D7 compatibility):
- add an option to skip varspez during parameters comparison
  - skip varspez comparison when searching a property reader candidate if $VARPROPSETTER is ON

git-svn-id: trunk@15020 -
2010-03-17 09:56:50 +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
florian
5d01732128 * several fixes which improve the behaviour of nested generics, resolves #15077
git-svn-id: trunk@14176 -
2009-11-14 22:24:55 +00:00
Jonas Maebe
5128a6726c * fixed type compatibility checking for classrefs and id
* modified test for this

git-svn-id: branches/objc@13724 -
2009-09-16 19:02:05 +00:00
Jonas Maebe
203609d09d * obj-c classrefdefs and id/pobjc_class are assignment-compatible
(a class type is also a class instance in obj-c, and id is
     assignment-compatible with all instance types)

git-svn-id: branches/objc@13685 -
2009-09-09 22:24:12 +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
112ea5e5a8 * made all objcclasses assignment-compatible with id, and vice versa
git-svn-id: branches/objc@13170 -
2009-05-17 20:04:43 +00:00
Jonas Maebe
3a8b29be91 + test conversion from class to differently sized enum and to differently
sized integer (succeed for Delphi, fail for objfpc)
  * fixed compiler so it only allows typecasting a class/interface to a
    differently sized integer in Delphi mode

git-svn-id: trunk@13152 -
2009-05-16 11:07:09 +00:00
Jonas Maebe
5a09f58526 * only allow implicit type conversions from dynamic arrays to voidpointer
in Delphi mode, rather than to any pointer type (confused overload
    selection in mantis #13639)

git-svn-id: trunk@13079 -
2009-05-02 12:50:14 +00:00
Jonas Maebe
5b08047d1c * allow exlicit type conversions from class/interface to enums in Delphi
mode (mantis #11859)
  * cleaned up some superfluous "eq=te_incompatible" checks (probably from
    copy/pasting conditions from elsewhere)

git-svn-id: trunk@13050 -
2009-04-26 20:41:24 +00:00
ivost
0f519439b5 * reverted r12690 and r12691
* but extended ptconst so that a com interface maybe assigned to a TGuid const

git-svn-id: trunk@12692 -
2009-02-06 02:56:13 +00:00
ivost
c61a0784cb * assign an Interface to TGuid was not possible (const Guid: TGuid = IUnknown)
git-svn-id: trunk@12690 -
2009-02-06 01:01:59 +00:00
florian
706f8085f4 * convert int64 properly to c-bools, resolves #12614
git-svn-id: trunk@12120 -
2008-11-16 13:27:59 +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
yury
8818df640f * Fixed passing of open array of wide string literals to function which expects 'array of pwidechar' parameter in case source file has utf8 encoding. Compiler thrown the following error in such case: Incompatible type for arg no. 1: Got "Array Of Const/Constant Open Array of WideString", expected "Open Array Of PWideChar".
+ Test for this issue.

git-svn-id: trunk@11581 -
2008-08-14 18:55:10 +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
tom_at_work
6958bbfdda * allow explicit conversion of enumeration values (in addition to integers) to object references in Delphi mode
git-svn-id: trunk@11398 -
2008-07-18 15:30:20 +00:00
florian
467aeb3446 * avoid ie 99080501 when overloading procedures with open arrays of widechar, resolves #11543
git-svn-id: trunk@11266 -
2008-06-23 18:50:51 +00:00
florian
e265393d7a * make stringconstn => open array of char a l1 conversion as it was earlier, resolves #10727
git-svn-id: trunk@10984 -
2008-05-17 18:18:51 +00:00
Jonas Maebe
85b9c65f51 * fixed support in macpas mode for anonymous procedure/function types
in parameter lists after r9484 (mantis #11254)

git-svn-id: trunk@10885 -
2008-05-05 11:59:35 +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
yury
801837f60d * Fixed bug #10681.
+ Test.

git-svn-id: trunk@9879 -
2008-01-23 10:24:04 +00:00
Jonas Maebe
08ccb30e3b * perform real "exactness" checking for open array parameters
git-svn-id: trunk@9624 -
2008-01-04 12:54:47 +00:00
Jonas Maebe
719c29cf86 + new cpo_openequalisexact parameter comparison option which
treats equal open arrays, open strings and arrays of const
    (implicitly also open) as exactly matching (since you
     cannot declare such types on their own, so they will
     never match exactly)
  * require that forward declared procedures match the
    implementation exactly for both the parameters (with
    the above modification) and result type (mantis
    #10425 and the related webtbf/tw10425a.pp)

git-svn-id: trunk@9484 -
2007-12-16 22:22:11 +00:00
florian
5c96c4a671 + first part of support for an unicodestring type
git-svn-id: trunk@9382 -
2007-12-02 16:39:13 +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
5bc156efea * always demote type conversions which cannot represent part of the
source value to convert_l3, instead of only those with a destination
    type whose size is < source size (like Delphi) + test -> fixes
    toperator6 along with a host of wrong tordconst typeconversions in
    the compiler sources themselves (although most are harmless)

git-svn-id: trunk@8323 -
2007-08-28 19:38:40 +00:00
daniel
6e0a7bb0eb * Nil constants that are type converted to a method procvar are now
properly converted. The conversion is done at runtime to generate
    a two pointer memory reference as result location, something
    which the code generator can handle very well, which minimizes
    the chance of side effects.

git-svn-id: trunk@7978 -
2007-07-07 20:57:05 +00:00
florian
76a3d55199 * allow enum => pointer type casts in delphi mode, resolves #8465
git-svn-id: trunk@7905 -
2007-07-01 14:43:46 +00:00
daniel
504d845e86 * Consider conversion from integer to integer te_equal, if the base types
are equal and the range of the from type fits in the to type. I.e.
    conversion from -10..10 to shortint is considered equal. This is correct
    because in this case, the from type can be used wherever the to type is
    used, i.e. the compiler never needs to do conversion at compile or run
    time.

git-svn-id: trunk@7814 -
2007-06-25 20:57:21 +00:00
florian
70284da435 * allow <any ordinal>(class/interface) type casts likewise it is allowed for class references and pointers
git-svn-id: trunk@7811 -
2007-06-25 20:08:34 +00:00