Browse Source

* generate implicit 0+<x> for +<x> expressions

git-svn-id: trunk@1556 -
peter 20 years ago
parent
commit
f1af7cfe8f
4 changed files with 44 additions and 0 deletions
  1. 2 0
      .gitattributes
  2. 3 0
      compiler/pexpr.pas
  3. 9 0
      tests/tbf/tb0176.pp
  4. 30 0
      tests/webtbs/tw4229.pp

+ 2 - 0
.gitattributes

@@ -4575,6 +4575,7 @@ tests/tbf/tb0174b.pp svneol=native#text/plain
 tests/tbf/tb0174c.pp svneol=native#text/plain
 tests/tbf/tb0174d.pp svneol=native#text/plain
 tests/tbf/tb0175.pp svneol=native#text/plain
+tests/tbf/tb0176.pp svneol=native#text/plain
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain
 tests/tbf/ub0158a.pp svneol=native#text/plain
@@ -6311,6 +6312,7 @@ tests/webtbs/tw4209.pp svneol=native#text/plain
 tests/webtbs/tw4215.pp svneol=native#text/plain
 tests/webtbs/tw4219.pp svneol=native#text/plain
 tests/webtbs/tw4223.pp svneol=native#text/plain
+tests/webtbs/tw4229.pp -text svneol=unset#text/plain
 tests/webtbs/tw4233.pp svneol=native#text/plain
 tests/webtbs/tw4234.pp svneol=native#text/plain
 tests/webtbs/tw4234a.pp svneol=native#text/plain

+ 3 - 0
compiler/pexpr.pas

@@ -2346,6 +2346,9 @@ implementation
              begin
                consume(_PLUS);
                p1:=factor(false);
+               { we must generate a new node to do 0+<p1> otherwise the + will
+                 not be checked }
+               p1:=caddnode.create(addn,genintconstnode(0),p1);
              end;
 
            _MINUS :

+ 9 - 0
tests/tbf/tb0176.pp

@@ -0,0 +1,9 @@
+{ %fail }
+
+{$mode objfpc} {$H+}
+begin
+   + ParamStr(0);
+   + ParamCount;
+   + Exit;
+   + WriteLN;
+end.

+ 30 - 0
tests/webtbs/tw4229.pp

@@ -0,0 +1,30 @@
+{ Source provided for Free Pascal Bug Report 4229 }
+{ Submitted by "Gerhard" on  2005-07-28 }
+{ e-mail: [email protected] }
+unit tw4229 ;
+
+interface
+
+  type
+    strobj = object
+               bs : string ;
+               ba : ansistring ;
+              end ;
+
+  operator := ( const a : ansistring ) z : strobj ;
+
+implementation
+
+  operator := ( const s : string ) z : strobj ;
+
+    begin
+      z.bs := s ;
+     end ;
+
+  operator := ( const a : ansistring ) z : strobj ;
+
+    begin
+      z.ba := a ;
+     end ;
+
+end.