summaryrefslogtreecommitdiff
path: root/tests/tbf
diff options
context:
space:
mode:
authorsvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2014-06-05 20:05:05 +0000
committersvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2014-06-05 20:05:05 +0000
commit56fb634d3af70593a7b0bbbcdaf9ecd248cb06ea (patch)
treea9d633ff88c8ab28e2a875cd1e3a9595069dd871 /tests/tbf
parent04b4cf2643b3bceec19a5a2e1dedb7408ad3fc2f (diff)
downloadfpc-56fb634d3af70593a7b0bbbcdaf9ecd248cb06ea.tar.gz
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: http://svn.freepascal.org/svn/fpc/trunk@27861 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests/tbf')
-rw-r--r--tests/tbf/tb0240.pp12
-rw-r--r--tests/tbf/tb0241.pp12
-rw-r--r--tests/tbf/tb0242.pp12
-rw-r--r--tests/tbf/tb0243.pp14
-rw-r--r--tests/tbf/tb0244.pp17
-rw-r--r--tests/tbf/tb0245.pp17
-rw-r--r--tests/tbf/tb0246.pp20
7 files changed, 104 insertions, 0 deletions
diff --git a/tests/tbf/tb0240.pp b/tests/tbf/tb0240.pp
new file mode 100644
index 0000000000..71520e8463
--- /dev/null
+++ b/tests/tbf/tb0240.pp
@@ -0,0 +1,12 @@
+{ %FAIL }
+
+program tb240;
+
+type
+ TTest = record
+ f: TTest;
+ end;
+
+begin
+
+end.
diff --git a/tests/tbf/tb0241.pp b/tests/tbf/tb0241.pp
new file mode 100644
index 0000000000..0e66f3947b
--- /dev/null
+++ b/tests/tbf/tb0241.pp
@@ -0,0 +1,12 @@
+{ %FAIL }
+
+program tb241;
+
+type
+ TTest = record
+ f: array[0..1] of TTest;
+ end;
+
+begin
+
+end.
diff --git a/tests/tbf/tb0242.pp b/tests/tbf/tb0242.pp
new file mode 100644
index 0000000000..71aef4050b
--- /dev/null
+++ b/tests/tbf/tb0242.pp
@@ -0,0 +1,12 @@
+{ %FAIL }
+
+program tb242;
+
+type
+ TTest = record
+ f: array[0..1] of array[0..1] of TTest;
+ end;
+
+begin
+
+end.
diff --git a/tests/tbf/tb0243.pp b/tests/tbf/tb0243.pp
new file mode 100644
index 0000000000..2c85fac46a
--- /dev/null
+++ b/tests/tbf/tb0243.pp
@@ -0,0 +1,14 @@
+{ %FAIL }
+
+program tb243;
+
+type
+ TTest = record
+ f: record
+ f: TTest;
+ end;
+ end;
+
+begin
+
+end.
diff --git a/tests/tbf/tb0244.pp b/tests/tbf/tb0244.pp
new file mode 100644
index 0000000000..ec37d3e031
--- /dev/null
+++ b/tests/tbf/tb0244.pp
@@ -0,0 +1,17 @@
+{ %FAIL }
+
+program tb244;
+
+{$modeswitch advancedrecords}
+
+type
+ TTest = record
+ type
+ TTestSub = record
+ f: TTest;
+ end;
+ end;
+
+begin
+
+end.
diff --git a/tests/tbf/tb0245.pp b/tests/tbf/tb0245.pp
new file mode 100644
index 0000000000..18f587bc92
--- /dev/null
+++ b/tests/tbf/tb0245.pp
@@ -0,0 +1,17 @@
+{ %FAIL }
+
+program tb245;
+
+{$modeswitch advancedrecords}
+
+type
+ TTest = record
+ type
+ TTestSub = record
+ f: array[0..1] of TTest;
+ end;
+ end;
+
+begin
+
+end.
diff --git a/tests/tbf/tb0246.pp b/tests/tbf/tb0246.pp
new file mode 100644
index 0000000000..004a0daad5
--- /dev/null
+++ b/tests/tbf/tb0246.pp
@@ -0,0 +1,20 @@
+{ %FAIL }
+
+program tb246;
+
+{$modeswitch advancedrecords}
+
+type
+ TTest = record
+ type
+ TTestSub = record
+ type
+ TTestSub2 = record
+ f: TTest;
+ end;
+ end;
+ end;
+
+begin
+
+end.