Browse Source

* fixed passing function results to const formal defs, see tbs/tb0490.pp

git-svn-id: trunk@56 -
florian 20 years ago
parent
commit
ac880214fc
3 changed files with 21 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 3 0
      compiler/htypechk.pas
  3. 17 0
      tests/tbs/tb0490.pp

+ 1 - 0
.gitattributes

@@ -4959,6 +4959,7 @@ tests/tbs/tb0486.pp svneol=native#text/plain
 tests/tbs/tb0487.pp svneol=native#text/plain
 tests/tbs/tb0487.pp svneol=native#text/plain
 tests/tbs/tb0488.pp svneol=native#text/plain
 tests/tbs/tb0488.pp svneol=native#text/plain
 tests/tbs/tb0489.pp svneol=native#text/plain
 tests/tbs/tb0489.pp svneol=native#text/plain
+tests/tbs/tb0490.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain

+ 3 - 0
compiler/htypechk.pas

@@ -1096,6 +1096,9 @@ implementation
                       (valid_addr in opts) and
                       (valid_addr in opts) and
                       (hp.resulttype.def.deftype=stringdef) then
                       (hp.resulttype.def.deftype=stringdef) then
                      result:=true
                      result:=true
+                 else
+                   if valid_const in opts then
+                     result:=true
                  else
                  else
                   CGMessagePos(hp.fileinfo,errmsg);
                   CGMessagePos(hp.fileinfo,errmsg);
                  exit;
                  exit;

+ 17 - 0
tests/tbs/tb0490.pp

@@ -0,0 +1,17 @@
+type
+  trecord = record
+    l : longint;
+  end;
+
+function test : trecord;
+  begin
+  end;
+
+procedure p(const c);
+  begin
+  end;
+
+begin
+  p(test);
+end.
+