Browse Source

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 -
svenbarth 13 years ago
parent
commit
bf9cb352b3
3 changed files with 32 additions and 3 deletions
  1. 1 0
      .gitattributes
  2. 10 3
      compiler/ptype.pas
  3. 21 0
      tests/webtbf/tw21363.pp

+ 1 - 0
.gitattributes

@@ -11641,6 +11641,7 @@ tests/webtbf/tw21087.pp svneol=native#text/plain
 tests/webtbf/tw21238.pp svneol=native#text/pascal
 tests/webtbf/tw21238.pp svneol=native#text/pascal
 tests/webtbf/tw2128.pp svneol=native#text/plain
 tests/webtbf/tw2128.pp svneol=native#text/plain
 tests/webtbf/tw2129.pp svneol=native#text/plain
 tests/webtbf/tw2129.pp svneol=native#text/plain
+tests/webtbf/tw21363.pp svneol=native#text/pascal
 tests/webtbf/tw21466.pas svneol=native#text/pascal
 tests/webtbf/tw21466.pas svneol=native#text/pascal
 tests/webtbf/tw2154.pp svneol=native#text/plain
 tests/webtbf/tw2154.pp svneol=native#text/plain
 tests/webtbf/tw21566.pp svneol=native#text/pascal
 tests/webtbf/tw21566.pp svneol=native#text/pascal

+ 10 - 3
compiler/ptype.pas

@@ -467,12 +467,19 @@ implementation
                 Message(parser_e_no_generics_as_types);
                 Message(parser_e_no_generics_as_types);
                 def:=generrordef;
                 def:=generrordef;
               end
               end
-            else if (def.typ=undefineddef) and (sp_generic_dummy in srsym.symoptions)
-                and parse_generic and
+            else if (def.typ=undefineddef) and
+                (sp_generic_dummy in srsym.symoptions) and
+                parse_generic and
                 (current_genericdef.typ in [recorddef,objectdef]) and
                 (current_genericdef.typ in [recorddef,objectdef]) and
                 (Pos(upper(srsym.realname),tabstractrecorddef(current_genericdef).objname^)=1) then
                 (Pos(upper(srsym.realname),tabstractrecorddef(current_genericdef).objname^)=1) then
               begin
               begin
-                def:=current_genericdef;
+                if m_delphi in current_settings.modeswitches then
+                  begin
+                    Message(parser_e_no_generics_as_types);
+                    def:=generrordef;
+                  end
+                else
+                  def:=current_genericdef;
               end
               end
             else if is_classhelper(def) and
             else if is_classhelper(def) and
                 not (stoParseClassParent in options) then
                 not (stoParseClassParent in options) then

+ 21 - 0
tests/webtbf/tw21363.pp

@@ -0,0 +1,21 @@
+{ %FAIL }
+
+{$MODE DELPHI}
+
+type
+  TWrapper<T> = record
+    procedure Z(a: TWrapper);
+      { TWrapper is an unspecialized generic type identifier and should not be
+        accepted here }
+  end;
+
+procedure TWrapper<T>.Z(a: TWrapper);
+begin
+end;
+
+var
+  wr: TWrapper<Integer>;
+
+begin
+  wr.Z(wr);
+end.