Commit Graph

198 Commits

Author SHA1 Message Date
florian
b684719f1e + give an error if allocated temps. overflow the normally max. available space
git-svn-id: trunk@30449 -
2015-04-05 20:59:34 +00:00
Jonas Maebe
e6d948470e * skip test in general for 64 bit cpus
git-svn-id: trunk@29947 -
2015-02-23 22:54:31 +00:00
svenbarth
5115c3e680 Fix for Mantis #26481. This is a regression.
nutils.pas, handle_staticfield_access:
  * generics don't have staticvarsyms for their static fieldvarsyms so we need to simulate a non-static access to avoid 1) an exception and 2) incorrect errors that instance methods can't be accessed

+ added tests

git-svn-id: trunk@29484 -
2015-01-16 16:05:53 +00:00
nickysn
84a18e57bc + added test for the error checking for nil-number; tests already exist for
nil+number and number+nil, so this was the only one missing

git-svn-id: trunk@28235 -
2014-07-18 12:09:27 +00:00
nickysn
6d54046300 * output a proper error message in case number+nil is encountered (just like
it's already done for nil+number and nil-number)

git-svn-id: trunk@28225 -
2014-07-15 22:26:58 +00:00
svenbarth
a7a9440692 Add a new warning message that is generated if an instance of an abstract class is created. This message is disabled by default, but can be switched on by using {$warn 4122 on} or {$warn 4122 error}.
Please note that this warning won't be triggered if an instance of that class is created using a class variable of that class type as the compiler can not know the type contained in the variable at compile time (see also the added test).

+ msg/errore.msg: added disabled message which informs about the instantiation of an abstract class
* pexpr.pas, do_member_read: generate the message if we have a constructor call for an abstract class using a loadvmtaddrnode (thus the type name is used and not a class variable)

* msg{idx,txt}.inc: updated

+ added test

git-svn-id: trunk@28127 -
2014-07-01 20:41:05 +00:00
svenbarth
639a59df92 Added support for partial specialization. This should fix a few problems with generics, the tests for which will be added in the next days after I've verified them.
For partial specialization only the declaration is reparsed, but not method bodies.

The way generic parameters are passed around inside the compiler is changed: instead of creating new type symbols we keep a (name,def) pair so that the code in insert_generic_parameter_types can decide whether it needs to add a type symbol (for new undefined defs) or not (for real types and undefined defs that were passed on from the parent generic). This required the tfpobjectlist type of the genericlist variables/parameters to be changed to tfphashobjectlist.

For correctly parsing Delphi specializations as parameters in functions of records (or objects) the relationship between the def and its typesym must already be established during the parsing. For this the checks for forcing a "type is not completely defined" message needed to be adjusted to correctly handle nested types as well. This should as a sideeffect also allow the usage of nested constants, etc like was fixed for classes some months ago.

ToDo: 
  - if a generic is specialized with only fully defined types then we could generate the in the unit where it's used. This is not yet done.
  - currently we don't specialize generics that are currently parsed; maybe this could be improved in the future for better type compatibility checks
  - check whether the pausing of token recording for partial specializations works correct in context of hint modifiers

pgenutil.pas:
  * parse_generic_parameters: return a tfphashobjectlist instead of a tfpobjectlist (requires a few type adjustments in various other declarations)
  * maybe_insert_generic_rename_symbol, insert_generic_parameter_types: change genericlist from tfpobjectlist to tfphashobjectlist
  * parse_generic_specialization_types_internal: use is_generic instead of checking for df_generic
  * generate_specialization:
      + add a nested function to disable the requirement to check for method bodies
      * use the "simple" parameter parsing only for error recovery
      * instead of already creating a new type symbol for a parameter we use the found symbol's name and its def and maybe create it later on (therefor the type of tfpobjectlist was changed to tfphashobjectlist)
      * a partial specialization is specialized into the symtable of the def it is specialized in instead of one of the two global symtables
      * for now we handle partial specializations of generics we are currently parsing like before
      * don't continue recording generic tokens while we do a partial specialization
      * use the new unset_forwarddef function on the newly created defs
  * insert_generic_parameter_types: only create a new type symbol if the found type symbol does not yet have an owner (thus was freshly created for this generic declaration)

pdecobj.pas, object_dec:
  * change type of genericlist from tfpobjectlist to tfphashobjectlist
  * set the type sym for all object types that can be generic or inside a generic (needed for correctly parsing Delphi style generic declarations)

pdecsub.pas, parse_proc_head:
  * consume_generic_interface: always generate the specialization name as now all generics are "specialized" inside a generic
  * the assumption that the def index numbers are the same is no longer true as the genericdef might contain the defs of partial specializations which are not generated for full specializations

pdecvar.pas, read_record_fields:
  * we also need to check nested types whether they contain a not yet completely parsed record or object

ptype.pas:
  * read_named_type: 
      * change genericlist from tfpobjectlist to tfphashobjectlist
      * pass the typesymbol along to record_dec
  * resolve_forward_types: use is_generic instead of checking for df_generic
  * single_type: 
      * use is_generic instead of checking for df_generic
      * no need to check generic parameters
  * parse_record_members:
      + add parameter for the record's type symbol
      * setup the typesym <=> def relationship
  + record_dec: add parameter for the type symbol and pass it to parse_record_members
  * read_named_type, expr_type: use is_generic instead of checking for df_generic
  * array_dec & procvar_dec: change genericlist from tfpobjectlist to tfphashobjectlist

symdef.pas, tstoreddef:
  * improve the checks used in is_generic and is_specialization to really only work on true generics and true (and partial) specializations respectively
  * don't search the type parameters in the symtable, but store them in the PPU and load them from there
  - remove fillgenericparas method (including the calls in the descendants tarraydef, tprocvardef, tobjectdef and trecorddef)

defcmp.pas, compare_defs_ext:
  * handle partial specializations: specializations with only undefineddefs are compatible to generic defs

pdecl.pas, types_dec:
  * switch generictypelist from tfpobjectlist to tfphashobjectlist

ppu.pas:
  * increase PPU version

+ added tests that ensure that "not completely defined" checks for records (and objects) still work correctly

git-svn-id: trunk@27861 -
2014-06-05 20:05:05 +00:00
nickysn
dcc2354760 * disallow 64-bit property index specifiers on 64-bit CPUs, since they were not
handled correctly there anyway (they were silently truncated to 32-bit)

git-svn-id: trunk@27061 -
2014-03-09 21:05:53 +00:00
svenbarth
2e186a91fa Add support for integer constants to SetPEFlags and SetPEOptFlags. This is Delphi compatible.
scandir.pas:
  + add function "get_peflag_const" to retrieve the value of a constant
  * dir_setpeflags & dir_setpeoptflags: first check for an identifier (value is retrieved through "get_peflag_const") and then read a value

+ added messages for illegal parameters for SetPEFlags and SetPEOptFlags respectively
+ added tests

git-svn-id: trunk@24887 -
2013-06-13 10:51:42 +00:00
svenbarth
3ad0de732e Added a test for a bug that was fixed in Delphi in (maybe XE4) to make sure that a similar bug will not be introduced in FPC.
Source: http://www.deltics.co.nz/blog/?p=1397

git-svn-id: trunk@24403 -
2013-05-01 19:13:18 +00:00
svenbarth
376bd046aa Don't allow "static" for class operators or normal methods (except in objects).
pdecsub.pas, pd_static:
  * check whether the given pd is an operator or a class method not inside an Object and generate an error if either of these is true
msg/errore.msg, msgidx.inc, msgtxt.inc:
  * add a message to inform that a certain procedure directive is not allowed

+ added tests

git-svn-id: trunk@23944 -
2013-03-20 10:46:55 +00:00
svenbarth
b5827ce363 Move the handling of "misstyled" floating point constants like "2." or "2.e10" from the scanner to the parser. This way type helpers calls for integer constants can be parsed correctly in the future.
Note: the error messages for incorrect "misstyled" floating point numbers (e.g. "2e10foo") have changed because of this.

scanner.pas, tscannerfile.readtoken:
  instead of tokenizing "2.", "2.e10", "2.e+10" and "2.e-10" as "_REALNUMBER" tokenize them as "_INTCONST _POINT", "_INTCONST _POINT _ID", "_INTCONST _POINT _ID _PLUS _INTCONST" "_INTCONST _POINT _ID _PLUS _INTCONST"; tokenizing of normal floating constants is not changed

pexpr.pas:
  factor: 
    * extract the code for creating a new constant floating point from "factor" into a new function "real_const_node_from_pattern"
    + allow the parsing of postfixoperators for integer constants if a "." is encountered
  + postfixoperators: check for a "misstyled" floating point number if an ordinal const (not an enum and not a boolean) is encountered (the code is already partially prepared for type helper support)
  
+ Added tests

git-svn-id: trunk@23356 -
2013-01-10 16:23:00 +00:00
svenbarth
359a228085 Fix one problem type of Mantis #23546. A record must not contain a static array that uses itself as an element type (in can contain a dynamic array however) otherwise an infinite loop is encountered when checking whether the record needs special init/final code.
pdecvar.pas, read_record_fields:
  * if the def of the field is a static array then use the array's element def (the final element def if it is a multi dimensional array) to check for whether this is the current record type

+ added tests

git-svn-id: trunk@23352 -
2013-01-09 14:07:01 +00:00
florian
e30ac89356 * moved test into the correct location and renamed
git-svn-id: trunk@20001 -
2012-01-07 21:56:23 +00:00
Jonas Maebe
293f09e41d * corrected test (only "overload" differences between interface/
implementation should cause compilation to fail)

git-svn-id: trunk@19494 -
2011-10-15 15:46:34 +00:00
Jonas Maebe
d8b008b0b0 * require that "overload" is present in the interface if it's used in the
implementation (Delphi-compatible in case multiple overloads exist in
    the current unit, and in other cases avoids compiler crashes in case
    of circular implementation dependencies)
  * ignore other symbol options (deprecated, legacy, platform, ...) as far as
    the interface crc is concerned to avoid trouble in case they appear in the
    implementation but not in the interface (to prevent compiler crashes)

git-svn-id: trunk@19492 -
2011-10-15 14:47:45 +00:00
Jonas Maebe
b0e83a06af * fixed crash when trying to index a record without a default property
git-svn-id: trunk@17480 -
2011-05-17 13:13:59 +00:00
Jonas Maebe
e78f195422 + new test that should fail to compile, but doesn't yet
git-svn-id: trunk@17034 -
2011-02-27 18:03:04 +00:00
paul
55a0fefb1f compiler: implement generic array type:
- add tarraysymtable to store generic type symbols
  - process generic and specialize declarations similar to generic records and classes
  - fix insert_generic_parameter_types to use def passed in argument instead of current_structdef because generic array type can't be assigned to the current_structdef variable
  - increase ppu version because of arraydef changes
  - tests

git-svn-id: trunk@16681 -
2011-01-02 13:16:17 +00:00
paul
04ac114c77 tests: move tb0070.pp to tbs and change expected behavior to success because delphi and fpc both allows this constructions now
git-svn-id: trunk@16647 -
2010-12-27 05:51:59 +00:00
florian
85225d437e + additional goto test
git-svn-id: trunk@15689 -
2010-08-02 19:35:44 +00:00
florian
c6ffbe9eda * support string constants > 255 chars
* don't cut off anymore string constants silently at 255 chars

git-svn-id: trunk@14789 -
2010-01-24 09:28:46 +00:00
paul
cb54b3e7a9 compiler: allow class to have local type sections + tests
git-svn-id: trunk@14605 -
2010-01-11 02:35:10 +00:00
Jonas Maebe
a1bcc1c8d2 * turn openstring value parameters into regular shortstring parameters
(mantis #14940 and #14941)
  * only turn var/our shortstring parameters with a length of 255 into
    openstring parameters with {$p+} (new tbf/tb0217.pp)

git-svn-id: trunk@14602 -
2010-01-10 15:36:23 +00:00
florian
6ea40be296 * fixed more properties, I still wonder how this could be commited
git-svn-id: trunk@13543 -
2009-08-16 10:57:52 +00:00
Jonas Maebe
c6733ed9a5 * disallow placing fields after method/property definitions, because this
can create ambiguities for the parser in case the field names also exist
    as modifiers (TP- and Delphi-compatible, mantis #13971) + tests
  * fixed tests that broke because of this change

git-svn-id: trunk@13334 -
2009-06-27 12:59:46 +00:00
Jonas Maebe
b7235b21c9 * no longer allow assigning values to typecasted properties, because in
case the getter is a function, the result is that first the getter is
    called, and subsequently the temp holding the function result is
    overwritten (thus not changing anything). This is Delphi-compatible,
    and fixes tests/tbf/tb0214*

git-svn-id: trunk@13320 -
2009-06-23 18:42:53 +00:00
Jonas Maebe
e6bf70fc05 * fixed/cleaned up tests for "nil + 1"
git-svn-id: trunk@13212 -
2009-05-30 11:29:54 +00:00
Jonas Maebe
7e908cb1e3 * forbid "nil +/- ordinal" expressions (Delphi-compatible, and the
expression is meaningless since nil is not a valid address)

git-svn-id: trunk@13205 -
2009-05-27 17:50:55 +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
ea356808b1 * tests have to fail
* "fixed" tests so they also fail on 32 bit platforms

git-svn-id: trunk@13149 -
2009-05-16 10:30:28 +00:00
ivost
cf7b755dc0 * additional negative testcase for interfaces
git-svn-id: trunk@12726 -
2009-02-08 23:10:43 +00:00
ivost
b2235eb873 * new negative test cases for interface to TGuid/Shortstring assign
git-svn-id: trunk@12724 -
2009-02-08 21:24:28 +00:00
Jonas Maebe
b3aa2ab759 + new test which should fail but doesn't yet (it should not be possible to
use a char typecasted as a chararray with more than one element as an
    lvalue)

git-svn-id: trunk@12708 -
2009-02-07 22:20:47 +00:00
Jonas Maebe
53213844d8 + new test (not yet fixed)
git-svn-id: trunk@12050 -
2008-11-11 20:20:29 +00:00
Jonas Maebe
e5920bc2b8 * delay verbosity changes just like localswitches changes
* store a node's verbosity in the node so that e.g. disabling warnings
    also disables warnings for this node in pass_1
   (the above together fix mantis #12076)
  * save/restore verbosity with {$push}/{$pop} (mantis #12075)
  * if warnings/notes/hints are turned off, also do not count encountered
    ones for the totals (otherwise -Sew cannot be used properly in
    combination with {$warnings off}, because disabled warnings will still
    trigger a compiler error) -- this required adding -vw/-vn/-vh to all
    tests using -Sew/-Sen/-Seh
  - removed some superfluous state saving/restoring from firstpass()

git-svn-id: trunk@12025 -
2008-11-03 21:18:27 +00:00
florian
57f3e2f40a * forbid access to properties in class methods
* readability fix

git-svn-id: trunk@11838 -
2008-09-28 20:16:13 +00:00
florian
d2214685c3 * fixes compiler crash with out of memory on illegal array declarations
git-svn-id: trunk@11505 -
2008-08-03 10:34:41 +00:00
tom_at_work
f11cf59854 * tests for checking type casts from integers/enums to TObjects in Delphi and non-Delphi mode (see r11398)
git-svn-id: trunk@11400 -
2008-07-18 15:53:37 +00:00
florian
050627ea1d * allow goto inside finally blocks
git-svn-id: trunk@11392 -
2008-07-17 19:49:38 +00:00
Jonas Maebe
87aa666768 + test I still had lying around
git-svn-id: trunk@10950 -
2008-05-12 09:51:19 +00:00
florian
4a243d451f + support of -Mxxx or $modeswitch to enable single mode specific features
git-svn-id: trunk@10936 -
2008-05-10 22:04:53 +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
61522d00a2 * fixed tests now that i386 assembler code is checked for correct PIC
usage in case PIC generation is on (some by adding PIC-versions of
    the assembler code, most by adding -Cg- to the options to be used).

    Note: the Intel assembler reader does not yet support the Delphi
    PIC construct, so tests with that (like test/tasmread and test/tcg1)
    do not work with -Cg on non-Darwin (Darwin needs a different PIC
    construct)

git-svn-id: trunk@9370 -
2007-12-01 14:34:50 +00:00
Jonas Maebe
f1f1f1c7cd + tests for wrong relsymbol usage
git-svn-id: trunk@9369 -
2007-12-01 14:27:45 +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
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
daniel
dafc044cea * tb0201 should now succeed, move & rename it to tbs/tb0540
* Add %FAIL & %NORUN to tb0200.

git-svn-id: trunk@7826 -
2007-06-26 17:43:41 +00:00
daniel
9eccba45e9 * Improve test.
git-svn-id: trunk@7824 -
2007-06-26 17:28:21 +00:00
daniel
eef2d4a1df + Discovered a bug regarding string bounds checking, add tests for it.
git-svn-id: trunk@7823 -
2007-06-26 17:23:49 +00:00