Răsfoiți Sursa

* make "formal const/var" parameters the least preferred conversion
(mantis #32179)
- removed code to handle conversion to formaldef parameters that are not by
reference (so the default conversion preference is kept)

git-svn-id: trunk@40012 -

Jonas Maebe 6 ani în urmă
părinte
comite
9bd931e931
4 a modificat fișierele cu 29 adăugiri și 7 ștergeri
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/defcmp.pas
  3. 1 6
      compiler/htypechk.pas
  4. 26 0
      tests/webtbs/tw32179.pp

+ 1 - 0
.gitattributes

@@ -16308,6 +16308,7 @@ tests/webtbs/tw32150.pp svneol=native#text/pascal
 tests/webtbs/tw3216.pp svneol=native#text/plain
 tests/webtbs/tw32160.pp svneol=native#text/plain
 tests/webtbs/tw3217.pp svneol=native#text/plain
+tests/webtbs/tw32179.pp svneol=native#text/plain
 tests/webtbs/tw3222.pp svneol=native#text/plain
 tests/webtbs/tw3226.pp svneol=native#text/plain
 tests/webtbs/tw3227.pp svneol=native#text/plain

+ 1 - 1
compiler/defcmp.pas

@@ -1880,7 +1880,7 @@ implementation
                else
                 { Just about everything can be converted to a formaldef...}
                 if not (def_from.typ in [abstractdef,errordef]) then
-                  eq:=te_convert_l2;
+                  eq:=te_convert_l6;
              end;
         end;
 

+ 1 - 6
compiler/htypechk.pas

@@ -1964,7 +1964,7 @@ implementation
               { all types can be passed to a formaldef,
                 but it is not the prefered way }
               if not is_constnode(fromnode) then
-                eq:=te_convert_l2
+                eq:=te_convert_l6
               else
                 eq:=te_incompatible;
             end;
@@ -2037,11 +2037,6 @@ implementation
       begin
         { Note: eq must be already valid, it will only be updated! }
         case def_to.typ of
-          formaldef :
-            begin
-              { all types can be passed to a formaldef }
-              eq:=te_equal;
-            end;
           stringdef :
             begin
               { to support ansi/long/wide strings in a proper way }

+ 26 - 0
tests/webtbs/tw32179.pp

@@ -0,0 +1,26 @@
+{$mode delphi}
+
+type
+  TGuidHelper = record helper for TGUID
+    Class Function Create(const Data): TGUID; overload; static; inline;
+    Class Function Create(const S: string): TGUID; overload; static;
+  end;
+
+class function TGuidHelper.Create(const Data): TGUID;
+begin
+  halt(1);
+end;
+
+class function TGuidHelper.Create(const S: string): TGUID;
+begin
+  writeln('B');
+end;
+
+var
+  c: PChar;
+  g: TGUID;
+begin
+  g.Create(utf8string(c)); // will print 'A'
+  g.Create(unicodestring(c)); // will print 'A'
+  g.Create(shortstring(c)); // will print 'A'
+end.