浏览代码

* 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 -

svenbarth 8 年之前
父节点
当前提交
70817baf98
共有 6 个文件被更改,包括 58 次插入7 次删除
  1. 2 0
      .gitattributes
  2. 1 3
      compiler/ptype.pas
  3. 28 0
      tests/tbs/tb0623.pp
  4. 27 0
      tests/tbs/tb0624.pp
  5. 0 2
      tests/test/tgeneric87.pp
  6. 0 2
      tests/test/tgeneric88.pp

+ 2 - 0
.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

+ 1 - 3
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 }

+ 28 - 0
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.

+ 27 - 0
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.

+ 0 - 2
tests/test/tgeneric87.pp

@@ -1,5 +1,3 @@
-{ %FAIL }
-
 program tgeneric87;
 
 {$mode objfpc}

+ 0 - 2
tests/test/tgeneric88.pp

@@ -1,5 +1,3 @@
-{ %FAIL }
-
 program tgeneric88;
 
 {$mode objfpc}