assembler .obj module. Note that TASM modules aren't fully supported yet,
because our OMF internal linker doesn't support all features of the OMF object
format. This test works, because it's really simple. As more OMF features are
supported, this test will be extended.
git-svn-id: trunk@32353 -
was correct before the ansistrings with codepage support had been
implemented, and by accident kept working afterwards on platforms that
don't use UTF-8 as defaultsystemcodepage, but after r31831 it started
failing. This commit fixes it again, in combination r31847 (by ensuring
that the string data passed to ansistart/endtext is encoded in
defaultsystemcodepage).
git-svn-id: trunk@31848 -
* extend parse_proc_head() with support for /parsing/ generic functions (at least in mode Delphi, mode ObjFPC depends on the new isgeneric parameter to be set)
* adjust parsing of interface mappings with a generic interface (note: in mode ObjFPC this now requires a "specialize" directly before the generic interface's name, which is more in line with other uses of "specialize")
pexpr.pas, factor:
* don't call postfixoperators() if hadspecialize is set
tests/test/tgeneric79.pp:
* adjust test to changed syntax
git-svn-id: trunk@31769 -
parameter instead of immediately doing it in the constructor of the call
node, and then only create it if we actually need it.
It was previously created in the call node constructor because it needs to be
done before pass_1 (which is where it is actually used) due to pass_1 possibly
being performed in the context of inlining (and then a wrong self parameter
may be found, or none at all), and it was done unconditionally because at that
point we don't know yet whether or not a self parameter will be necessary (as
we haven't resolved the overloads/procdef yet).
The problem with this is that if we use the parentfpstruct way of handling
accesses to outer scope locals/parameters, we need to know all locals/
parameters that will be accessed from nested routines after typecheckpass,
otherwise we get crashes. The problem was that if a call to an RTL routine was
generated by the compiler in a routine nested inside a method during pass_1,
and this nested routine itself did not access self of the method (so self was
not added to its parentfpstruct during the typecheckpass), then the
unconditional reference to self when creating the call caused a compiler
crash (introduced in r30908)
git-svn-id: trunk@31197 -
class, which conflicts with java.lang.System in recent jdk javac's
(and we don't access any of the RTL classes explicitly in the
test program)
git-svn-id: trunk@30952 -
sizeint" function that returns:
<0: invalid sequence detected after processing "-result" bytes
0: incomplete (may still be valid if MaxLookAhead is increased)
>0: sequence of result bytes forms a codepoint (+ combining diacritical
marks if that parameter was true)
git-svn-id: trunk@30047 -
instead of the frame pointer register:
1) we exactly know the offsets of the temps from the stack pointer
after pass 1 (based on the require parameter stack size for called
routines), while we don't know it for the frame pointer (it depends
on the number of saved registers)
2) temp offsets from the stack pointer are positive while those from
the frame pointer are negative, and we can directly encode much
bigger positive offsets in the instructions
o move the stack pointer register to a virtual register in
loadparentfpn, because many instructions cannot directly operate
on/with the stack pointer
o add the necessary register interference edges for the stack pointer
register
git-svn-id: trunk@29938 -
type
TTestLongInt = specialize SomeOtherUnit.TTest<LongInt>;
will now have to read as
type
TTestLongInt = SomeOtherUnit.specialize TTest<LongInt>;
While this is not backwards compatible this situation should arise seldomly enough and the benefits especially in context with generic functions/procedures/methods outway the drawbacks.
pbase.pas:
* try_consume_unitsym: add a allow_specialize parameter that allows to parse "specialize" in front of a non-unit symbol; whether it was a specialization or not is reported using a new is_specialize parameter
+ add a new overload try_consume_unitsym_no_specialize that calls try_consume_unit sym with allow_specialize=false and a dummy is_specialize parameter
* switch calls to try_consume_unitsym to try_consume_unitsym_no_specialize
pstatmnt.pas, try_statement:
* switch call to try_consume_unitsym to try_consume_unitsym_no_specialize
* adjust call to parse_nested_types
ptype.pas:
+ extend id_type with the possibility to disallow unit symbols (needed if a specialize was already parsed) and to report whether a specialize was parsed
+ extend parse_nested_types with the possibility to tell it whether specializations are allowed
* have parse_nested_types specialize generic defs if one is encountered and local type defs are allowed
* id_type: only allow "unitsym.specialize sym" or "specialize sym", but not "specialize unitsym.sym"
* single_type: correctly handle specializations with "specialize" keyword
* read_named_type.expr_type: there is no longer a need to check for "specialize" keyword
pexpr.pas:
+ new function handle_specialize_inline_specialization which tries to specialize a type symbol
* handle_factor_typenode: handle specializations after a point that follows a record or object (why isn't this part of postfixoperators anyway? O.o)
* postfixoperators: handle "specialize" after records and objectdefs
* factor_read_id: handle "specialize" in front of an identifier (and after unit symbols)
+ added tests
* adjusted test webtbs/tw16090.pp
git-svn-id: trunk@29768 -
loading them from ppu (like was already done when they were initially
compiler), so they can be called via the "id" type even if no classes are
in scope that implement them
git-svn-id: trunk@29686 -
an Objective-C method masks an identifier from a category, because due
to the fact that all standard categories are imported at the same time via
the CocoaAll unit, this can often happen with categories you don't know/
care about. These errors also didn't happen in 2.6.x
git-svn-id: trunk@29497 -
ptype.pas, id_type:
* don't generate an error if the undefineddef typesym is an explicit rename that belongs to a generic
+ added test
git-svn-id: trunk@29485 -
tests/test/tthlp22.pp:
* this test fails no longer as Mode Delphi by default also contains modeswitch TypeHelpers
* adjust program name for consistency
git-svn-id: trunk@29274 -
fpc_ansistr_to_widechararray(), so that CP_ACP/CP_OEM etc are properly
handled (fixes assign/assignfile with non-ansi characters in source files
that don't explicitly specify the code page)
git-svn-id: trunk@29218 -
pgenutils.pas, check_generic_constraints:
* correctly handle forward defs if the constraint is either a single IInterface/IUnknown or a TObject/class
+ added tests
git-svn-id: trunk@28601 -
procvar in the local state of the block, and then call it insde the
generated invoke routine. We can't call it directly there, because
due to visibility reasons it may not be accessible from a regular
procedure (e.g. if it is a strict private method)
git-svn-id: branches/blocks@28234 -
"reference to ...; cdecl;". The "reference to ..." syntax is what Delphi
uses for anonymous function references. The "cdecl;" indicates that this
is for the C-variant of such references, which is what blocks are
git-svn-id: branches/blocks@28233 -
o blocks are implemented as a variation of procedure variables
o declaration of a block variable: "test: procedure(c: char) is block;"
(C equivalent: (void)(^test)(char c) )
o the compiler automatically converts procedures/functions whose address
is passed to a block parameter or assigned to a block variable into
a "block". This consists of
1) generating a block descriptor (containing the size of the "block
literal" (see below) and the signature of the invocation function
encoded as an Objective-C selector)
2) generating a wrapper function around the original funcion (with C
calling convention), that has an extra first hidden parameter
(marked as vo_is_parentfp in the compiler) whose type is a pointer
to the describing "block literal"
3) generating the "block literal", which contains a pointer to an
external variable indicating whether this block captures context or
not, some flags (see compiler/blockutl.get_block_literal_flags for
info), a pointer to the wrapper function and a pointer to the
descriptor. In the future, it will also contain captured variables.
o right now, only global procedures/functions can be converted to blocks
(because they don't require state capturing). The next steps are (Object
Pascal) methods (not Objective-C methods, because Objective-C method
procvars don't exist) and finally nested functions
o on Mac OS X, the functionality will only work on Mac OS X 10.7 and later,
because we have to use the so-called "ABI.2010.3.16" to ensure that
our blocks aren't called as variadic functions by the runtime (which
came out after the Mac OS X 10.6 release)
o while the currently implemented functionality does not require any
library support at all, there's no use enabling it on other platforms
because unless it has been confirmed to work with a blocks runtime,
there's no point in using blocks (they're just somewhat bulky procvars
right now). Enabling it on other platforms (in combination with the
GNUStep Objective-C run time), should simply be a matter of adding
the right {$linklib xxx} statement to rtl/inc/blockrtl.pp file, adding
that file to Makefile.fpc for that platform and adding that platform
to the compiler/systems.systems_blocks_supported set
git-svn-id: branches/blocks@28232 -
tests that execute a child process. Otherwise, by default, all DOS memory is
reserved in these memory models, there's no DOS memory left for the child
process and exec() fails.
git-svn-id: trunk@28061 -
implemented on two FPC platforms (go32v2 and msdos). On the platforms that
don't need it, it does nothing, so it's safe to call on all platforms.
git-svn-id: trunk@28060 -
o only create an accessor wrapping the inherited accessor at a
potentially lower visibility level if the overriding property
itself does not specify a different accessor to use
o simplified code
o tests
git-svn-id: trunk@27954 -
Currently it is implemented only for x86-CPUs supporting the FMA extension. While it would
be possible to implement it in software or simulate fma(<single>,<single>,<single>) using
double operations, it makes no sense in my opinion to do so.
git-svn-id: trunk@27564 -
+ globtype.pas: add new modeswitch to modeswitch enum and name array
* ptype.pas & pdecobj.pas: check for new modeswitch instead of modeswitch class
* ppu.pas: increase ppu version as we've added a new modeswitch which requires correctly compiled units
* adjusted tests to enabled the modeswitch when necessary
+ added three new tests that check for correct functionality of modeswitch typehelpers
git-svn-id: trunk@26796 -
o set the code page of the temporary "text" file to utf-8 for writestr with
unicodestring/widestring as destination, so that no data loss can occur
(+ properly deal with cases whereby part of an utf-8 character is
written to the textbuf in this case)
o explicitly pass the code page of the destination ansistring for writestr
with ansistring as destination and set it for the temporary "text" file
o set the code page of the text file for readstr
git-svn-id: trunk@26317 -
Max Nazhalov) and use that code by default on the JVM target
* adapted JVM tests for the new str<->float code similar to how the
generic tests were adapted
git-svn-id: trunk@25954 -
based on the Grisu1 algorithm. This corrects several precision issues
with the previous code used to perform such conversions (patch by
Max Nazhalov, mantis #25241)
o adaptation of several tests to deal with the better precision of these
routines compared to the previous version
Please don't remove the real2str.inc file yet, it's still used by the
JVM target for now
git-svn-id: trunk@25888 -
-CTlowercaseprocstart
o convert all consecutive uppercase characters at the start to lowercase
instead of only the first one. Exception: if there is more than one
such character and the last one is followed by a lowercase character,
assume the last uppercase character belongs to the second word (like
in FPCIsGreat) and don't lowercase that one
+ test
git-svn-id: trunk@25845 -
* don't allow to apply the same hint directive twice
* change parser_e_proc_dir_not_allowed to more generic variant parser_e_dir_not_allowed - they are similar and 'procedure' prefix does not give more information about the error.
* maybe_parse_hint_directives() uses procdef settings for initial values
+ add tests
git-svn-id: trunk@25720 -
symtable.pas:
+ add new tsymbol_search_flag type which can be passed to various searchsym* routines
+ add support to not call "addsymref"
+ add new searchsym_with_flags function that calls searchsym_maybe_with_symoption
* adjust searchsym_maybe_with_symoption, searchsym_in_class & searchsym_in_helper to use new flag type instead of Boolean arguments
* adjust searchsym & searchsym_with_symoption which call the modified functions
nutils.pas, handle_staticfield_access:
* adjust searchsym_in_class call
pexpr.pas, handle_factor_typenode, postfixoperators, factor:
* adjust searchsym_in_helper and searchsym_in_class calls
pinline.pas, new_function:
* adjust searchsym_in_class call
scanner.pas, try_consume_nestedsym:
* adjust searchsym_in_class call
fmodule.pas, tmodule:
+ add genericdummysyms field which is a TFPHashObjectList that contains TFPObjectList instances per generic dummy that in turn contains tgenericdummysyms instances
pgenutil.pas:
+ add function split_generic_name to split a generic name into non-generic name and count value of type parameters
+ add function resolve_generic_dummysym which tries to use the new genericdummysyms field to find the real symbol of a dummy sym
* generate_specialization: adjust searchsym_in_class call
* specialization_init/specialization_done: save/restore genericdummysyms of module
symdef.pas, tdefawaresymtablestack:
+ add new intermediate method pushcommon which is used by both push and pushafter
+ add new intermediate method remove_helpers_and_generics (which calls remove_generics and remove_helpers if necessary)
* rename removehelpers to remove_helpers
* rename addhelpers to add_helpers_and_generics and extend it to correctly fill current_module.genericdummysyms
* call remove_helpers_and_generics from pop instead of remove_helpers
ptype.pas, single_type, read_named_type.expr_type, read_named_type:
* try to resolve symbols with sp_generic_dummy with resolve_generic_dummysym
+ added test
git-svn-id: trunk@25519 -
rtl/objpas/classes/classesh.inc, TStringList:
* rename the private ExchangeItems to ExchangeItemsInt and allow inlining
+ add a protected virtual ExchangeItems
rtl/objpas/classes/stringl.inc, TStringList:
* Exchange: call ExchangeItemsInt
+ let default implementation of ExchangeItems simply call ExchangeItemsInt
* QuickSort: call ExchangeItemsInt directly if there is no override otherwise call ExchangeItems
+ added test
git-svn-id: trunk@25480 -
support for arbitrarily encoded ansistrings to many routines related to
file system access (and some others).
WARNING: while the parameters of many routines have been changed from
"ansistring" to "rawbytestring" to avoid data loss due to conversions,
this is not a panacea. If you pass a string concatenation to such a
parameter and not all strings in this concatenation have the same
code page, all strings and the result will be converted to
DefaultSystemCodePage (= ansi code page by default). In particular,
concatenating e.g. an Utf8String with a constant string and passing
the result to a RawByteString parameter will convert the result into
the DefaultSystemCodePage (unless the source code is compiler with
{$modeswitch systemcodepage} or {$mode delphiunicode} *and* the ansi
code page on the system you are compiling *on* happens to be UTF-8)
You can define and use alternative routines that explicitly accept
Utf8String parameters to avoid this pitfall. Internally, all of these
routines ensure that they never trigger this condition and ensure that
not unnecessary/unwanted code page conversions occur.
+ DefaultFileSystemCodePage variable that holds the code page used for
communicating with the OS single byte file system APIs, and for the
strings returned by those same APIs. Initialized with
o the result of GetACP in the system unit of Windows platforms, except for
WinCE which uses UTF-8 since its file system OS API calls already use
the UTF-16 versions
o CP_UTF8 on Unix platforms with FPCRTL_FILESYSTEM_UTF8 defined, and with
DefaultSystemCodePage on other Unix platforms
o DefaultSystemCodePage on Java/Android JVM targets
+ DefaultRTLFileSystemCodePage variable that holds the code page used to
encode strings returned by RTL routines that return filenames obtained
from OS API calls. By default the same as DefaultFileSystemCodePage on
all platforms. Separate from DefaultFileSystemCodePage for clarity on
platforms that may use either utf-16 or single byte OS API calls to
send/receive file names (such as most Windows platforms)
+ new scpFileSystemSingleByte enum that can be passed to
GetStandardCodePage() to get the default code page for OS single byte file
system APIs, with implementations for Unix and Windows
+ SetMultiByteFileSystemCodePage() procedure to override the value of
DefaultFileSystemCodePage
+ ToSingleByteFileSystemEncodedFileName() function to convert a string to to
DefaultFileSystemCodePage (does *not* take care of OS-specific quirks like
Darwin always returning file names in decomposed UTF-8)
+ support for CP_OEMCP
* textrec/filerec now store the filename by default using widechar. It is
possible to switch back to ansichars using the FPC_ANSI_TEXTFILEREC define.
In that case, from now on the filename will always be stored in
DefaultFileSystemEncoding
* fixed potential buffer overflows and non-null-terminated file names in
textrec/filerec
* when concatenating ansistrings, do not map CP_NONE (rawbytestring) to
CP_ACP (defaultsystemcodepage), because if all input strings have the
same code page then the result should also have that code page if it's
assigned to a rawbytestring rather than getting defaultsystemcodepage
* do not consider empty strings to determine the code page of the result
in fpc_AnsiStr_Concat_multi(), because that will cause a different
result than when using a sequence of fpc_AnsiStr_Concat() calls (it
ignores empty strings to determine the result code page) and it's also
slower
* do not consider the run time code page of the destination string in
fpc_AnsiStr_Concat(_multi)() because Delphi does not do so either. This
was introduced in r19118, probably to hide another bug + test
* never change the code page of a non-empty string when calling setlength on
it
* handle the fact that GetEnvironmentStringsA returns the environment in the
OEM instead of in the Ansi code page (mantis #22524, #15233)
* don't truncate environment variable strings in GetEnvironmentString(),
its result is now ansistring/unicodestring depending on whether the
RTL was compiled with FPC_RTL_UNICODE
* unix:
o made the ansistring parameters of the fp*() file system routine overloads
constant, changed them to rawbytestring and added
DefaultFileSystemCodePage conversions
o unicodestring support for POpen(), and DefaultFileSystemCodePage support
for POpen(RawByteString)
+ DefaultFileSystemCodePage support for dynlibs unit
+ rawbytestring/unicodestring overloads for:
o system: fexpand, lowercase, uppercase, getdir, mkdir, chdir, rmdir,
assign, erase, rename
o objpas: AssignFile,
o sysutils: FileCreate, FileOpen, FileExists, DirectoryExists, FileSetDate,
FileGetAttr, FileSetAttr, DeleteFile, RenameFile, FileSearch, ExeSearch,
FindFirst, FindNext, FindClose, FileIsReadOnly, GetCurrentDir,
SetCurrentDir, ChangeFileExt, ExtractFilePath, ExtractFileDrive,
ExtractFileName, ExtractFileExt, ExtractFileDir, ExtractShortPathName,
ExpandFileName, ExpandFileNameCase, ExpandUNCFileName,
ExtractRelativepath, IncludeTrailingPathDelimiter,
IncludeTrailingBackslash, ExcludeTrailingBackslash,
ExcludeTrailingPathDelimiter, IncludeLeadingPathDelimiter,
ExcludeLeadingPathDelimiter, IsPathDelimiter, DoDirSeparators,
SetDirSeparators, GetDirs, ConcatPaths, GetEnvironmentVariable
-- the default string type used by FindFirst/Next depends on whether the
RTL was compiled with FPC_RTL_UNICODE. To force the RawByteString
version pass a TRawByteSearchRec, for the UnicodeString version pass
a TUnicodeSearchRec.
+ paramstr(longint):unicodestring available for {$modeswitch unicodestrings}
+ pwidechar versions in sysutils of strecopy, strend, strcat, strcomp,
strlcomp, stricomp, strlcat, strrscan,strlower, strupper, strlicomp,
strpos, WideStrAlloc, StrBufSize, StrDispose + tests
git-svn-id: trunk@25432 -
determine whether (wide)char->pchar will be preferred over (wide)char ->
p(wide)char or not (always convert to pchar if mode switch is not active,
otherwise always to pwidechar). Delphi-compatible + consistent with the
behaviour added for constant strings in that revision + tests
git-svn-id: branches/cpstrrtl@25430 -
when building the mangled name, because the latter can also be performed
when compiler another unit (and therefore if that other unit's setting
is different from that of the original unit, a wrong mangled name was
generated) + test for this case
git-svn-id: trunk@25388 -
that may trigger JVM bytecode verification errors if they are used
before they are initialised (this includes passing them as a "var"
parameter) + test
* sorted -CT parameters alphabetically and alligned them
git-svn-id: trunk@25387 -
so that code written according to Delphi coding standards can be compiled
into JVM bytecode with routine names conforming to JVM coding standards
git-svn-id: trunk@25385 -
The previous code deleted the newly inserted instruction instead of the
existing one, which obviously broke code.
Assembly:
mov r0, r0, lsr #23
mov r0, r0, lsr #23
transformed into:
mov r0, r0, lsr #23
expected was:
mov r0, #0
The problem only shows up in the very unlikely case of two LSR/ASR or
two LSL following on each other and having a total shift of more than 31
bits.
This fixes test/opt/tarmshift.pp
I've also removed the {%norun} directive from tarmshift.pp as this test
does only make sense when it also runs.
git-svn-id: trunk@25374 -
o these routines are now generic wrappers in filutil.inc, and call
the platform-dependent internalfindfirst/next/close routines
o on unix, the fnmatch routine got proper support for UTF-8 matching
(e.g., it won't match a partial UTF-8 code point to a "?" wildcard)
o for NativeNT, a similar (untested) UTF-16 version has been added
+ test for the above
* rawbytestring/unicodestring versions of fileage
git-svn-id: branches/cpstrrtl@25302 -
other than DefaultFileSystemCodePage, so that it can work with strings
holding any encoding
+ test for fexpand(ansistring) with UTF-8 strings while DefaultSystemCodePage
is set to CP_ASCII
git-svn-id: branches/cpstrrtl@25300 -
a property in a child class has a higher visibility than the getter/
setter), ensure that we call the inherited method and not the method
itself (causing a stack overflow due to infinite recursion)
git-svn-id: trunk@25223 -
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 -
symtype.pas, tdef:
+ add method "fullownerhierarchyname" which allows to retrieve the owner hierarchy name including procedure/function/method names
+ add method "fulltypename" which uses "fullownerhierarchyname" to return a full type name
symdef.pas, tstoreddef:
* implement "fullownerhierarchyname" (including caching of the result)
pgenutil.pas, parse_generic_specialization_types_internal:
* use "tdef.fulltypename" instead of "tdef.typename" to have unique values for each parsed type and thus for the specialization itself
+ tests
git-svn-id: trunk@25175 -
CP_ACP (defaultsystemcodepage), because if all input strings have the
same code page then the result should also have that code page if it's
assigned to a rawbytestring rather than getting defaultsystemcodepage
* do not consider empty strings to determine the code page of the result
in fpc_AnsiStr_Concat_multi(), because that will cause a different
result than when using a sequence of fpc_AnsiStr_Concat() calls (it
ignores empty strings to determine the result code page) and it's also
slower
* do not consider the run time code page of the destination string in
fpc_AnsiStr_Concat(_multi)() because Delphi does not do so either. This
was introduced in r19118, probably to hide another bug
+ test
git-svn-id: branches/cpstrrtl@25143 -
code page of a rawbytestring influences the code page of concatenated
strings assigned to it (this behaviour will be fixed/changed in the
next commit)
git-svn-id: branches/cpstrrtl@25142 -
* renamed platform-specific pchar versions of those rouines to do_*() and
changed them to either rawbytestring or unicodestring depending on the
FPCRTL_FILESYSTEM_SINGLE_BYTE_API/FPCRTL_FILESYSTEM_TWO_BYTE_API setting
* implemented generic shortstring versions of those routines on top of either
rawbytestring or unicodestring depending on the API-kind (in case of the
embedded target, if ansistring are not supported they will map directly
to shortstring routines instead)
* all platform-specific *dir() routines with rawbytestring parameters now
receive their parameters in DefaultFileSystemCodePage
- removed no longer required ansistring variants from the objpas unit
- removed no longer required FPC_SYS_MKDIR etc aliases
* factored out empty string and inoutres<>0 checks from platform-specific
*dir() routines to generic ones
o platform-specific notes:
o amiga/morphos: check new pathconv(rawbytestring) function
o macos TODO: convert PathArgToFSSpec (and the routines it calls) to
rawbytestring
o nativent: added SysUnicodeStringToNtStr() function
o wii: convert dirio callbacks to use rawbytestring to avoid conversion
+ test for unicode mk/ch/rm/getdir()
git-svn-id: branches/cpstrrtl@25048 -
compiled with unicodestring)
* changed uppercase/lowercase(ansistring) to use the same logic as the
new unicode versions (unify code for lower/upper, only make result
unique if necessary)
+ test for all four routines
git-svn-id: branches/cpstrrtl@25006 -
(strecopy, strend, strcat, strcomp, strlcomp, stricomp, strlcat, strrscan,
strlower, strupper, strlicomp, strpos, WideStrAlloc, StrBufSize,
StrDispose)
* adjusted pwidechar version of strnew to call WideStrAlloc instead of
StrAlloc
+ tests for several newly added sysutils pwidechar routines based on
existing tests for equivalent pchar routines
* converted several sysutils ansistr*() function tests to tests for str*
functions
git-svn-id: branches/cpstrrtl@24998 -
o resolved conflict in updated morphos sysutils unit
o moved code that had been added to the now deleted sysunix.inc to the
unix-specific block of the fpwidestring unit's init code
git-svn-id: branches/cpstrrtl@24913 -
* typinfo.pp: the newly introduced records were added into {$PACKRECORDS 1} area of effect, which effectively made all records packed, entirely defeating FPC_REQUIRES_PROPER_ALIGNMENT purpose.
* added alignment between TProcedureParam records, adjusted TProcedureSignature.GetParam() appropriately.
* ncgrtti.pas: added two missing alignments and removed a redundant one.
* tests/test/trtti9.pp: modified to use TProcedureSignature.GetParam() and endian-independent check for parameter flags.
git-svn-id: trunk@24562 -
- TotalSize of all array dimensions instead of first dimension size
- Element type of last array dimension
- dimension information
rtl:
- adopt array initialization/finalization/copy for the new tkArray RTTI
- add Delphi compatible TArrayTypeData member for typinfo.TTypeData structure
tests:
- add a test which checks RTTI information for 2 dimension array
git-svn-id: trunk@24458 -
function result as a variable, and Delphi/TP-like "using the function name
inside the function means a recursive call". In order to prevent
confusion, we no longer support the former behaviour since r21817
because the conditions under which one or the other holds are not well
defined and it's easier to fix a compiler error then to discover why
a recursive function call doesn't do anything (mantis #22344)
git-svn-id: trunk@24182 -
ptype.pas, parse_record_members:
* write an error message if "protected" or "strict protected" is encountered
msg/errore.msg:
+ add an error message for disallowed "things" in records
+ added test
* adjusted test (note: according to the bug report this test did not originally have the "protected" section, but it was added by Paul before commiting)
git-svn-id: trunk@23596 -
symconst.pas:
+ extend "thelpertype" by "ht_type" which tells the code in "pdecobj.parse_extended_type" that a type helper declaration has been parsed
node.pas:
+ add a constant which identifies all constant node types
ptype.pas:
+ read_named_type: add a parameter "hadtypetoken" to tell the code whether a "type" token had been parsed before
+ read_named_type: if an identifier "helper" is parsed we need to check whether "hadtypetoken" is true and the modeswitch "m_class" is set, but the "m_delphi" one is not; in that case we have a "type helper" declaration
pgenutil.pas, generate_specialization:
* adjust call to read_named_type
pdecl.pas, types_dec:
* adjust call to read_named_type
pdecobj.pas:
* parse_extended_type: extend for correct handling of primitive types (includes Delphi compatible handling as well) and reject types that are explicitly not allowed
* method_dec: require "static" for class methods in type helpers
* method_doc: allow constructors for type helpers as well
paramgr.pas, tparamanager:
* set_common_funcretloc_info: handle type helper constructors like record constructors
* handle_common_ret_in_param: the "self" value of a type helper constructor is also returned in a parameter
pexpr.pas:
+ add a function to postfixoperators which tries to find and apply a type helper for a given type
* postfixoperators: try to apply type helpers for ordinal constants
* postfixoperators: use the correct string type for string constants
* postfixoperators: try to apply type helpers for enum constants
* postfixoperators: try to apply type helpers for arrays
* postfixoperators: try to apply type helpers for Variant
* postfixoperators: try to apply type helpers for pointer types
* postfixoperators: try to apply type helpers for other types
* factor: check postfixoperators after _REALNUMBER, _CCHAR, _CWCHAR, _TRUE and _FALSE
* factor: also check postfixoperators if a _POINT follows a _NIL
symdef.pas, tdefawaresymtablestack.addhelpers:
* use "generate_objectpascal_helper_key" to generate the key
symtable.pas:
+ add function to generate the key value for the map of extended types using the extended def
* adjust "search_last_objectpascal_helper" and "search_objectpascal_helper" to handle primitive types as well
* use the new "generate_objectpascal_helper_key" function to generate the key
pparautl.pas:
* insert_self_and_vmt_para: don't insert the $vmt symbol for record or type helpers (ToDo: check whether class helpers really need the symbol as well)
* insert_self_and_vmt_para: pass "self" as var parameter for type helpers as well
psub.pas, generate_bodyentry_block:
* also allow type helpers for constructor methods
ncal.pas, tcallnode.gen_self_tree:
* also use a temp variable for type helper constructors
ncgcal.pas, tcgcallnode.secondcallparan:
* allow Pointers to be passed as address param if it is the Self value of a type helper extending a pointer type
* correctly handle the location in case of type helper constructors
+ add tests
git-svn-id: trunk@23580 -
have to wrap an existing (g|s)etter that was marked as "abstract" (don't
mark the helper also as abstract, sicnce it contains code)
git-svn-id: trunk@23545 -
scanner.pas, parse_compiler_expr.read_factor:
+ allow "<>" after "declared" (handle "<>" operator specially)
+ count "," to get correct amount of type parameters
+ check together with the count string for symbols
+ correctly handle dummy symbols
+ added tests
git-svn-id: trunk@23544 -
raised because it was automatically raised in the parent class (can happen
for the JVM target when letting the compiler generate getters/setters for
properties)
git-svn-id: trunk@23522 -
symconst.pas:
+ extend "tdefoptions" by a "df_genconstraint" which will be used to mark dummy defs that should mainly satisfy the compiler's type checking without to much changes
symsym.pas:
+ add a class "tgenericconstraintdata" which will hold information about the constraints associated with a specific generic type parameter (designed for future extensions)
+ extend "ttypesym" by a reference to a "tgenericconstraintdata" which is written to the ppu only if needed
symtype.pas:
+ add a pointer to "tderef" as this is needed for the ppu reading/writing code for the "tgenericconstraintdata"
pdecl.pas, types_dec:
+ call "parse_generic_parameters" so that constraints are allowed
pgenutil.pas:
+ extend "generate_specialization" by a "parsedpos" to give in the file position of the first parsed parameter (needed for correct error locations when checking the constraints)
+ add an overloaded call of "generate_specialization" to differentiate between the use cases "first parameter parsed by generate_specialization" and "first parameter parsed by other code"; this also allows to write the "fillchar" for the "parampos" parameter only once ( => otherwise a warning is triggered => error in compilation)
+ extend the "parse_generic_specialization_types" by a "poslist" parameter which will contain the positions of all parsed type parameters (can only be used in the case that all parameters are parsed)
* move the original code of "parse_generic_specialization_types" to a new procedure "parse_generic_specialization_types_internal" which take an additional "parsedpos" parameter which will be added to the "poslist" before all others; "parse_generic_specialization_types" calls this new procedure with a dummy argument (which won't be used)
+ extend "parse_generic_parameters" by the parsing of generic constraints which constructs correct defs for the parameters and fills in the new "tgenericconstraintdata" object for each parameter (note: the "constructor" constraint is only parsed for Delphi compatibility and basically means the same as a "class" constraint... (it's a relict of Delphi.NET))
* adjust "insert_generic_parameter_types" as specializations and generics can no longer be differed by whether the type parameters are of type "undefineddef"
pdecsub.pas, parse_proc_head, consume_generic_interface:
* adjust call to "generate_specialization"
+ add a new function "check_generic_constraints" which is used from within "generate_specialization" to ensure that the given specialization parameters are compatible with the constraints of the generic parameters
ptype.pas:
* single_type: adjust call to "generate_specialization"
* read_named_type, expr_type: adjust call to "generate_specialization"
+ write_persistent_type_info: don't write typeinfo for constraints
pexpr.pas, sub_expr:
* adjust call to "generate_specialization"
* adjusted ppudump, because of added "tdefoptions.df_genconstraint" value
+ added tests for generic constraints
* modified test for class helper inside a generic which extends a class type parameter
+ added test for record helper inside a generic which extends a record type parameter
git-svn-id: trunk@23158 -
beyond the 64kb per method limit (so that all tests can be compiled/run
with the -Co command line parameter to check that functionality against
false positives)
git-svn-id: trunk@22810 -
add it everywhere in the paramanagers (where it was often forgotten)
- removed places where it was explicitly added to cdecl_pocalls checks
+ test
git-svn-id: trunk@22616 -
* fixed accessibility checking for strict_protected (the class
in which the access occurs also has to be related to the
objectdef of which a symbol is accessed) + test
git-svn-id: trunk@22565 -
their nested tree already contains the load (subscriptn) for the variable
itself and there is no clean/easy way to avoid that in a completely
portable way in ncgnstld + test
git-svn-id: trunk@22519 -
The WinCE implementation converts the rawbytestring arguments to
unicodestring and calls unicode OS APIs, while the others convert
unicodestring arguments to DefaultFileSystemCodePage and call
single byte OS APIs
+ test for the above
git-svn-id: branches/cpstrrtl@22467 -
type that contains managed types, but this child doesn't contain any
managed type itself (since r16632, the parent should be considered as a
field of the child in terms of needing initialization/finalization)
git-svn-id: trunk@22461 -
The cause of the internal error was the following:
We have a generic in an unit ("A") which uses another unit ("B") in the implementation section and this other unit uses unit A in the interface section. Now the generic is specialized in the interface section of B. This leads to the problem that in unit A when it tries to load the globalsymtable of unit B that globalsymtable will be Nil, because parsing of the interface section is not yet finished. Thus the change in pgenutil.pas, specialization_init: if the unit is still "in_interface" the localsymtable needs to be used instead of the globalsymtable.
This doesn't necessarily lead to a compiling test though, as there is the following possibility:
Unit A contains a generic class/record (with methods) and uses unit B in the implementation section. This unit B also contains a generic class/record (with methods) and uses unit A in the implementation section. Both units contain a specialization of the other unit's generic outside of it's own generics (such that generate_specialization is fully triggered). Let's assume compilation starts with unit A and we reach the uses of unit B. Now compilation switches to unit B and completes as unit A is already registered and in compilation. The problem now is that the generic in unit A still contains unresolved forward declarations as the implementation section of A was not yet parsed which will lead to "forward declaration not solved" errors (Note: Delphi compiles this).
The solution to this is the following: if a generic is specialized from another unit which is not in state ms_compiled then the unit of the specialization needs to wait for the unit of the generic. So the specialization's unit adds itself into a list of waiting units of the generic's unit. Now inside "proc_unit" we need to check whether this module is waiting for other modules and if so avoid "finishing" the unit (which means generating the methods of the specialization, generating assembler code and ultimately freeing the scanner and PPU). Now when the generic's unit finishes we need to check whether other modules are waiting for it and finish them (of course it's a bit more complicated in reality, but that pretty much sums it up).
+ globstat.pas: Added an unit which handles the saving and restoring of the global state which was originally inside "parser.pas, compile" so that Don't Repeat Yourself (DRY) is respected.
* fmodule.pas, tmodule:
+ add fields to keep track of the units the module is waiting for and which modules are waiting for the module
+ add field for the saved global state (raw pointer to avoid circles)
+ add field for the state which is needed to finish the unit (raw pointer to avoid circles)
+ move the code which was used in "parser.pas, compile" after a module was successfully compiled to the new virtual method "end_of_parsing"
+ fppu.pas, tppumodule.end_of_parsing:
free the ppufile here
* pgenutil.pas:
+ add new procedure "maybe_add_waiting_unit" which adds the specialization's unit to the waiting list of the generic if that unit is not yet compiled
* generate_specialization: call the new function when we add a new (true) specialization
* specialization_init: instead of not adding implementation units at all check whether the unit is still parsing the interface section and add the localsymtable in that case
* pmodules.pas:
* change "proc_unit" to a function which returns "true" if the unit was already finished (no need to wait for other units)
+ move the code from "proc_unit" from "generate_specialization_procs" on to a new procedure "finish_unit" which
* this procedure is either called immediately in "proc_unit" if the unit does not need to wait for other units or from "finish_unit" itself if a unit that is waiting for the given unit does no longer wait for another module (special care is taken in proc_unit to avoid circles)
* parser.pas, compile:
* correctly handle the case if an unit is not finished
* use the new global state functionality from globstat.pas
* pay special attention when calling "set_current_module" (see comment at that call)
+ add tests from 22160
+ add test for above mentioned "diamond" case
git-svn-id: trunk@22452 -
* only check whether the message identifier of an Objective-C method
matches the one from a method with the same name in a parent class
if the parameters match (todo: should be refined to "if the
encoded Objective-C selector names match")
git-svn-id: trunk@22373 -
* check "A op B" and "B op A" again for operators that can be commutative (all binary ones except shl, shr, div, mod, **, / and -)
* also check for Nil for classrefdefs if left side is a pointer (allows "TClass var" <>/= Nil again, after the above changes)
* don't allow overloads for "implicit pointer type <>/= pointer" and the other way around (this fixes non compiling Objective Pascal test tobjc21.pp and also the new toperator87.pp test)
* some formating corrections
+ added test for "TObject <> Pointer"
+ added test for "TClass <>/= Nil"
git-svn-id: trunk@21983 -
The changes are built up in a way that all operators on two given types are not allowed if a default implementation for that operator exists. This implies that there is a possibility to have a overload work for (in this order) type A and B, but not for B and A. This is for example the case for Set + Enum (which seems to have a default implementation) where Enum + Set is allowed. The added tests try to detect as many default implementations as feasible, but can't cover everything...
git-svn-id: trunk@21975 -
hierarchies from other units that were compiled without debug information
in case not all classes from the hierarchy are explicitly used
(mantis #22495, #21503, #21259)
git-svn-id: trunk@21972 -
(tf_safecall_clearstack is set for it) -> also use pocalls_cdecl for it
and adjust the safecall tests not to try parameter scenarios that are
unsupported for cdecl
git-svn-id: trunk@21948 -
* test/tcg1.pp: rewrote without PIC, was having the same issue (GOT off by 1), additionally Intel syntax part won't compile anyway. This test is about push/pop encoding, not about PIC.
git-svn-id: trunk@21811 -
symtable.pas, searchsym_in_class:
* if we found a helper method that has overload defined we should not forget the symbol as there can be a case that no method with that name is defined in the extended class hierarchy
symtable.pas, searchsym_in_record:
* analogous to the above
+ added test given in the issue
+ added analogous test for record helpers
git-svn-id: trunk@21764 -
This fixes 64bit shifts on arm with a constant shift value of 0.
The old code would have emitted something like this
mov r0, r0, lsl #32
as 32 is an invalid shift value (and would be wrong anyway) the
assembler declined to assemble the produced source.
The new code will just not emit any code for a shift value of 0.
tests/test/tint642.pp now tests shl/shr 0 on 64 bit values.
tests/webtbs/tw22326.pp is also added as an additional test.
git-svn-id: trunk@21746 -
with the enum instance corresponding to ordinal 0 in JVM constructors,
because a virtual method called by a parent constructor may already
have assigned a different value (see tests/test/jvm/tenum2.pp). This
will result in null pointer exceptions when using such fields without
first explicitly assigning a value to them though.
The old behaviour can be restored with the new -CTenumfieldinit command
line parameter
git-svn-id: trunk@21736 -
ptype.pas:
* read_named_type:
allow specializations for pointers in Delphi modes
* single_type:
correctly handle forwarddefs; as we can only specialize generics if
they are completely defined (srsym<>nil) we don't need to return a
forward def, but instead return the specialized def itself
+ added tests to "test" instead of "webtbs" as no explicit tests were given
in the report
git-svn-id: trunk@21689 -
ptype.pas:
* read_named_type:
after reading the type we're pointing to we need to make sure that
we didn't get a generic dummy symbol; this can happen when parsing
a pointer declaration as the type in a constant or variable
declaration
* resolve_forward_types:
when resolving forward types we need to make sure that we weren't
given a generic dummy to which no non-generic definition was
given (possible in Delphi mode); for non-Delphi modes we can not
rely on the generic dummy flag as the typedef of the symbol will
the generic def
+ added test from the bug reports as well as three additional ones to
make sure that nothing breaks regarding to forward pointer
declarations
git-svn-id: trunk@21687 -
* pgenutil.pas: factor out the reading of generic specialization parameters (parse_generic_specialization_types) and the generation of a generic type name (generate_generic_name)
* pdecsub.pas, parse_proc_head:
* also allow an interface alias declaration if an identifier is followed by a "<" (which starts a specialization)
+ add a procedure "consume_generic_interface" which parses such a specialization (by using "parse_generic_specialization_types") - this is needed, because "consume_generic_type_parameter" can (and should not!) handle "ISomeIntf<Integer, T>" or (somewhen in the future) "ISomeIntf<TSomeOtherGeneric<T>>" - and finds the correct symbol for the interface (by utilizing the "generate_generic_name" function)
* generate the correct mapping entry (for the generic it's only needed for checking (if any), but for a specialization it's essential that we reference the correct specialization)
+ add tests which were included with the issue and also two additional ones
Note: In non-Delphi modes an interface alias can be done like in Delphi mode; "specialization" is not necessary and furthermore not even allowed!
git-svn-id: trunk@21656 -
+ pgenutil.pas:
add a procedure which adds a type symbol to a non-Delphi-mode generic class or record which has the same name as the unit global dummy symbol for that generic. I don't know why I had that idea earlier as this will simplify some of the conditions in the parser again (I haven't changed these yet, but I hope to do that at least when I start working on generic functions).
* pgenutil.pas, generate_specialization:
correctly handle "specialize TSomeGeneric<T>" as method parameter in a generic with the newly added rename symbol
* pdecobj.pas, object_dec & ptype.pas, record_dec:
call the procedure to add the rename symbol (the procedure checks whether the mode is correct)
* ppu.pas:
increase PPU version so that we don't use non-Delphi mode units with generics, but without the rename symbol
+ added tests:
the one in webtbs are for classes/objects and those in test are for records
git-svn-id: trunk@21603 -