From 70817baf983ece1a99bf8fd7f45619e5beb7523f Mon Sep 17 00:00:00 2001 From: svenbarth <pascaldragon@googlemail.com> Date: Tue, 6 Dec 2016 21:37:22 +0000 Subject: [PATCH] * since we already allow inline specializations in mode ObjFPC due to generic functions it's only consequential to also allow specializations after pointers (they are already allowed in mode Delphi). + added tests * tgeneric87.pp and tgeneric88.pp are no longer considered as tests that should fail git-svn-id: trunk@35078 - --- .gitattributes | 2 ++ compiler/ptype.pas | 4 +--- tests/tbs/tb0623.pp | 28 ++++++++++++++++++++++++++++ tests/tbs/tb0624.pp | 27 +++++++++++++++++++++++++++ tests/test/tgeneric87.pp | 2 -- tests/test/tgeneric88.pp | 2 -- 6 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 tests/tbs/tb0623.pp create mode 100644 tests/tbs/tb0624.pp diff --git a/.gitattributes b/.gitattributes index 1916c937f5..d37ee33d8a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11051,6 +11051,8 @@ tests/tbs/tb0619.pp svneol=native#text/pascal tests/tbs/tb0620.pp svneol=native#text/pascal tests/tbs/tb0621.pp svneol=native#text/plain tests/tbs/tb0622.pp svneol=native#text/plain +tests/tbs/tb0623.pp svneol=native#text/pascal +tests/tbs/tb0624.pp svneol=native#text/pascal tests/tbs/tb205.pp svneol=native#text/plain tests/tbs/tb610.pp svneol=native#text/pascal tests/tbs/tb613.pp svneol=native#text/plain diff --git a/compiler/ptype.pas b/compiler/ptype.pas index f37c14879a..b209663b31 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -1562,7 +1562,6 @@ implementation const SingleTypeOptionsInTypeBlock:array[Boolean] of TSingleTypeOptions = ([],[stoIsForwardDef]); - SingleTypeOptionsIsDelphi:array[Boolean] of TSingleTypeOptions = ([],[stoAllowSpecialization]); var p : tnode; hdef : tdef; @@ -1695,8 +1694,7 @@ implementation begin consume(_CARET); single_type(tt2, - SingleTypeOptionsInTypeBlock[block_type=bt_type]+ - SingleTypeOptionsIsDelphi[m_delphi in current_settings.modeswitches] + SingleTypeOptionsInTypeBlock[block_type=bt_type]+[stoAllowSpecialization] ); { in case of e.g. var or const sections we need to especially check that we don't use a generic dummy symbol } diff --git a/tests/tbs/tb0623.pp b/tests/tbs/tb0623.pp new file mode 100644 index 0000000000..4303b312d4 --- /dev/null +++ b/tests/tbs/tb0623.pp @@ -0,0 +1,28 @@ +{ %NORUN } + +program tb0623; + +{$mode objfpc} +{$modeswitch advancedrecords} + +type + generic TTest<T> = record + public type + PSelf = ^specialize TTest<T>; + public + Next: PSelf; + end; + + generic TTest2<T> = record + Next: ^specialize TTest2<T>; + end; + + TTestLongInt = specialize TTest<LongInt>; + TTestString = specialize TTest<String>; + + TTest2LongInt = specialize TTest2<LongInt>; + TTest2String = specialize TTest2<String>; + +begin + +end. diff --git a/tests/tbs/tb0624.pp b/tests/tbs/tb0624.pp new file mode 100644 index 0000000000..4a009088fa --- /dev/null +++ b/tests/tbs/tb0624.pp @@ -0,0 +1,27 @@ +{ %NORUN } + +program tb0624; + +{$mode delphi} + +type + TTest<T> = record + public type + PSelf = ^TTest<T>; + public + Next: PSelf; + end; + + TTest2<T> = record + Next: ^TTest<T>; + end; + + TTestLongInt = TTest<LongInt>; + TTestString = TTest<String>; + + TTest2LongInt = TTest2<LongInt>; + TTest2String = TTest2<String>; + +begin + +end. diff --git a/tests/test/tgeneric87.pp b/tests/test/tgeneric87.pp index 33e2afc92c..3986caca72 100644 --- a/tests/test/tgeneric87.pp +++ b/tests/test/tgeneric87.pp @@ -1,5 +1,3 @@ -{ %FAIL } - program tgeneric87; {$mode objfpc} diff --git a/tests/test/tgeneric88.pp b/tests/test/tgeneric88.pp index c8233ee7e2..bb070f50fb 100644 --- a/tests/test/tgeneric88.pp +++ b/tests/test/tgeneric88.pp @@ -1,5 +1,3 @@ -{ %FAIL } - program tgeneric88; {$mode objfpc}