Commit Graph

367 Commits

Author SHA1 Message Date
svenbarth
fb8b0e7a27 Fix for Mantis #24453. Check for nested types after a specialization. Additionally check correctly whether a type is really a generic before accepting it when parsing a generic.
pgenutil.pas, generate_specialization:
  * use "is_generic" instead of "df_generic in defoptions" as nested non generic types will have that flag set as well and thus would be acceptable for the "<...>" notation although no generic version of it exists
ptype.pas, single_type:
  * check for nested types after doing a specialization

+ added tests (one for now working case and one for now forbidden case)

git-svn-id: trunk@25578 -
2013-09-26 09:21:28 +00:00
paul
93f1ba4493 compiler: don't allow to access an enum members through the enum member. It should be only possible throught the enum type name. Fixes issue #0025029
git-svn-id: trunk@25493 -
2013-09-16 02:48:52 +00:00
svenbarth
b6bfa864d4 Disallow the usage of the inline assembler inside generics, because there are currently two problems:
1. At least on x86 the assembler reader initializes the parameter location informations which results in InternalError 200301231
2. Assembler tokens are not stored in the token stream and thus won't be reproduced during specialization

x86/rax86int.pas, tx86intreader.Assemble:
  * check for "parse_generic" before calling generate_parameter_info
pstatmnt.pas, assembler_block & statement:
  * generate an error message if an asm statement should be parsed inside a generic

+ added test

git-svn-id: trunk@24892 -
2013-06-13 19:42:49 +00:00
florian
0968d095ed * convert function like used new into a appropriate nodes only in pass_1 so proper error checking can be carried out, resolves #24495
git-svn-id: trunk@24667 -
2013-05-31 14:55:49 +00:00
Jonas Maebe
11d5d4f79d * check range of enums and booleans in typed constant expressions when
using the asmlist generator (mantis #24428)

git-svn-id: trunk@24495 -
2013-05-14 12:05:00 +00:00
Jonas Maebe
3a03586ca9 * give an error when declaring a class as conforming to a forward-declared
interface: the compiler does not/cannot check whether the class
    implements all required methods in that case, and it moreover leads to
    crashes (mantis #24184). Older versions of Delphi did allow this (and
    don't check whether the interface methods are implemented either), but
    that's simply a (similar) bug in Delphi that has been fixed in XE at
    least
  * fixed compilation of webtbs/tw2727 after this fix

git-svn-id: trunk@24177 -
2013-04-07 12:18:31 +00:00
Jonas Maebe
1244cdff70 * don't treat bitpacked arrays of subranges of char that can be represented
using less than 8 bits per element the same as regular char arrays as far
    as automatic type conversions are concerned (they have to be explicitly
    packed/unpacked) (mantis #24013)

git-svn-id: trunk@23739 -
2013-03-09 10:37:30 +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
svenbarth
29bd000a4a Fix for Mantis #23571.
ptype.pas, single_type:
  * if using a message that expects a parameter, provide that parameter...

+ added tests

git-svn-id: trunk@23349 -
2013-01-09 11:28:17 +00:00
svenbarth
27f5e4f582 Fix for Mantis #23547. Basically we now fail with nicer error messages.
pgenutil.pas:
  generate_specialization:
    + instead of giving an internal error if "symname" is empty and "tt" is "nil" we now do an error recovery by parsing the specialization parameters and returning an errordef (this happens if the "generic" type before the "<" is not found)
    * handle "<>" specially by giving an approbiate error message (both when doing a recovery/parsing a generic and during normal specialization)
  parse_generic_parameters:
    * set the "block_type" to "bt_type" to be on the safe side
    * don't continue with inspecting the def (especially hard typecasting) if the found def is not an "objectdef"

Added tests.

git-svn-id: trunk@23344 -
2013-01-08 09:05:11 +00:00
Jonas Maebe
439741178d * test has to fail: add { %fail } and moved to webtbf
git-svn-id: trunk@22803 -
2012-10-21 17:28:20 +00:00
Jonas Maebe
5ea03973d3 * reject assignments to vecn[rangen] (mantis #22941)
git-svn-id: trunk@22434 -
2012-09-21 22:42:30 +00:00
Jonas Maebe
17c495595c * made variable public so got warning gets triggered
git-svn-id: trunk@22244 -
2012-08-25 21:32:38 +00:00
Jonas Maebe
4d0e4e1b56 * treat "[var + rip]" in intel assembler mode as addr_pic_no_got on x86-64
(mantis #22665)
  + support "[var wrt ..gotpcrel]" nasm/yasm syntax in intel assembler mode
    for GOT-relative accesses on x86-64, + give an error when trying to do
    this on win64 (it doesn't have a GOT)
  * moved code that give a warning when using GOT-relative accesses to
    static data on x86-64 from the AT&T reader to rax86 so it's also
    active for the Intel assembler reader
  + added warning when not using GOT-relative accesses (but plain
    RIP-relative instead) to global data on non-Win64 x86-64

git-svn-id: trunk@22243 -
2012-08-25 15:12:49 +00:00
Jonas Maebe
288d1ec74a * support referencing "result" in nostackframe pure assembler routines if
the result location is a simple location (a single register/reference)
    (mantis #22490)
  * print an error when accessing "result" in a nostack pure assembler routine
    if the result location is not simple

git-svn-id: trunk@22166 -
2012-08-21 19:51:40 +00:00
Jonas Maebe
aad3ce960a * give an error when trying to give a parameter of a non-simple type a
default value (mantis #22343)
  * give an error when specifying an invalid default value (e.g. a
    floating point number for a longint parameter)

git-svn-id: trunk@22021 -
2012-08-06 20:13:20 +00:00
Jonas Maebe
b1d00b66ac * fixed internalerror after invalid type node in subscript node
(mantis #22395)

git-svn-id: trunk@21917 -
2012-07-15 18:17:29 +00:00
svenbarth
8c95ea039f Fix for Mantis #22219
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 -
2012-06-24 10:08:17 +00:00
Jonas Maebe
50659b7e7f * give an error if a routine definition defines default values for
parameters that do not appear in forward/interface definitions
    (mantis #19434)
  * added test for #17136 already works

git-svn-id: trunk@21524 -
2012-06-07 22:36:39 +00:00
svenbarth
bf9cb352b3 ptype.pas, single_type: If the generic dummy type is used in mode Delphi then generate an error. This fixes Mantis #21363.
git-svn-id: trunk@21496 -
2012-06-06 13:15:18 +00:00
Jonas Maebe
f8cb3fbfef + old tests I forgot to commit
git-svn-id: trunk@21429 -
2012-05-29 09:01:55 +00:00
Jonas Maebe
5e6aaccca9 * removed spaces from empty line at start to prevent (unpatched) dbdigest
from crashing

git-svn-id: trunk@21150 -
2012-04-30 20:13:09 +00:00
sergei
c08ab0f745 * Re-raising exceptions must be allowed only in 'except' block itself, not in 'try' block of a nested try..except statement. Mantis #21873.
git-svn-id: trunk@21100 -
2012-04-28 15:59:34 +00:00
pierre
0c144e8bbc Test fix for bug report 21566
git-svn-id: trunk@20636 -
2012-03-26 15:50:09 +00:00
florian
0f9b8c8936 * don't throw an error if a non-generic is tried to be specialized, resolves #21238
git-svn-id: trunk@20607 -
2012-03-23 20:32:40 +00:00
pierre
f8dcacd69b *Explicitly disable range check to trigger the hint that is tested and no range check generated warning
git-svn-id: trunk@20601 -
2012-03-23 15:16:29 +00:00
florian
fbc519faeb * don't allow multiple deprecated messages, resolves #21466
git-svn-id: trunk@20515 -
2012-03-12 21:39:43 +00:00
Jonas Maebe
5c56b1bc3d * give an error when trying to take address of a global label declared in
another scope instead of crashing (mantis #21078)

git-svn-id: trunk@20508 -
2012-03-10 23:24:43 +00:00
Jonas Maebe
bacdd8be81 * don't ever mark the function result as vs_initialised, also not when
it is passed as a hidden parameter (mantis #20907)

git-svn-id: trunk@20373 -
2012-02-17 16:25:50 +00:00
Jonas Maebe
e5c097a6e2 * mark nodes that have been created by transforming a read-accessor of
of a property with nf_no_lvalue flag, and check that such nodes are
    never used in direct assignments (fixes mantis #21087 and a couple of
    other cases of invalid assignments to properties)

git-svn-id: trunk@20140 -
2012-01-21 19:09:30 +00:00
paul
889196f1c8 compiler: don't allow to execute instance methods, use instance fields and properties from the nested class (bug #0020721)
git-svn-id: trunk@19681 -
2011-11-25 08:33:24 +00:00
Jonas Maebe
84bf45f0e2 * give an error when trying to call an interface/protocol/category method
using the type name of the interface/protcol/category (they are not
    entities themselves on which you can invoke those methods,
    mantis #20661)

git-svn-id: trunk@19651 -
2011-11-18 22:33:33 +00:00
paul
b8589d98cc compiler: Don't allow duplicate property/procedure identifiers inside object declaration. The code which allowed this for delphi mode was initially written based on invalid test from mantis #0009176. Fixes bug #0020580.
git-svn-id: trunk@19564 -
2011-10-31 05:35:40 +00:00
florian
df75368d0b --- Merging r19281 into '.':
U    compiler\pdecsub.pas
U    compiler\symdef.pas
U    compiler\pdecobj.pas
U    compiler\htypechk.pas
U    compiler\ncal.pas
U    compiler\symtable.pas
--- Recording mergeinfo for merge of r19281 into '.':
 U   .
--- Merging r19282 into '.':
A    tests\webtbf\tw19975.pp
--- Recording mergeinfo for merge of r19282 into '.':
 G   .

git-svn-id: trunk@19343 -
2011-10-03 20:43:19 +00:00
Jonas Maebe
d714eeb84b * give a proper error when a type identifier is missing in a
class operator declaration (mantis #19213)

git-svn-id: trunk@19226 -
2011-09-25 14:38:06 +00:00
Jonas Maebe
dff5ac3b0a * don't allow passing a field of a record that's not an lvalue as
var-parameter, nor allowing taking its address (mantis #20095)

git-svn-id: trunk@19199 -
2011-09-23 21:21:49 +00:00
paul
1e3239915f merge r19074 from cpstrnew branch by paul:
tests: fix 2 tests. $FFFF chars are now valid characters for the compiler

git-svn-id: trunk@19126 -
2011-09-17 14:23:58 +00:00
sergei
bbae63a4f2 * Check that a single interface is only delegated to a single property within a class.
* Disallow simultaneous use of method resolution and delegation for the same interface. An interface with method resolution must be implemented directly. This is Delphi compatible and resolves #18058.

git-svn-id: trunk@18179 -
2011-08-12 14:42:30 +00:00
sergei
25bf0012f2 * When the interface method mapping is present, being unable to find the implementing procedure using the mapped name is a error condition. No attempt to find implementing procedure using symbol name should be made in this case. Resolves #19591.
git-svn-id: trunk@18166 -
2011-08-10 21:33:39 +00:00
florian
93e53e1990 * allow also smaller values for code alignment parameters than the current one, resolves #19463
* limit code alignment parameters to power of 2 up to 256
* give an error for an invalid code alignment directive

git-svn-id: trunk@17659 -
2011-06-04 20:56:15 +00:00
sergei
08ff5ff051 * x86 Intel assembler reader: disallow more than one register name per register operand, resolves #15672.
git-svn-id: trunk@17507 -
2011-05-19 20:00:15 +00:00
paul
e77a9051c8 compiler: treat record/class fields types as bt_var_type block in delphi mode - as result they don't create a forward declaration for ^Type. Leave it as is for other modes because in other case it break the compilation of RTL and packages (fixes issue #0018620)
git-svn-id: trunk@16832 -
2011-01-29 07:32:10 +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
paul
3ceee496d6 tests: fail test tw9509: disable type section in generic interfaces
git-svn-id: trunk@16680 -
2011-01-02 10:51:51 +00:00
Jonas Maebe
3a089cea10 * give an error when trying to let an objcclass conform to a
forward-declared objcprotocol (mantis #17341)

git-svn-id: trunk@16523 -
2010-12-08 22:17:24 +00:00
florian
7d1627e9ca * patch by Aleksa Todorovic to handle access to types inside generics correctly
when they are used as class variables, resolves #18096

git-svn-id: trunk@16474 -
2010-11-29 09:37:09 +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
db8a67747d * give an error when trying to use (bit)sizeof on a type that is not yet
resolved by the compiler (mantis #14354)

git-svn-id: trunk@16112 -
2010-10-08 17:42:53 +00:00
Jonas Maebe
bd0567563c * don't crash in {$x-} mode if a call cannot be resolved due to an error
in the expression (mantis #17455)

git-svn-id: trunk@16061 -
2010-09-29 12:11:22 +00:00
Jonas Maebe
9273856e84 * disallow pusha*/popa* for x86_64 (mantis #14862)
* disallow pushfd/popfd for x86_64 (mantis #14862)
  * fixed assembling popfq with the internal assembler (it needs a rex.w
    prefisx, while pushfq doesn't)
  * changed the default opcode size of pushf/popf/pusha/popa in
    {$asmmode intel} from "native size" to 16 bit (compatible with Intel
    manuals and Kylix; in AT&T mode, the default size for those operations
    remains the native one)
  * changed pushf/popf in rtl/i386/* into pushfd/popfd because of the
    previous change

git-svn-id: trunk@15546 -
2010-07-10 16:22:46 +00:00