Browse Source

* allow any untyped parameter to be passed to a untyped constref parameter
+ added test

git-svn-id: trunk@41829 -

svenbarth 6 years ago
parent
commit
307ff071e6
4 changed files with 41 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 8 0
      compiler/htypechk.pas
  3. 5 1
      compiler/ncal.pas
  4. 27 0
      tests/tbs/tb0656.pp

+ 1 - 0
.gitattributes

@@ -11823,6 +11823,7 @@ tests/tbs/tb0652.pp svneol=native#text/pascal
 tests/tbs/tb0653.pp svneol=native#text/plain
 tests/tbs/tb0654.pp svneol=native#text/plain
 tests/tbs/tb0655.pp svneol=native#text/pascal
+tests/tbs/tb0656.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

+ 8 - 0
compiler/htypechk.pas

@@ -192,6 +192,7 @@ interface
     procedure set_unique(p : tnode);
 
     function  valid_for_formal_var(p : tnode; report_errors: boolean) : boolean;
+    function  valid_for_formal_constref(p : tnode; report_errors: boolean) : boolean;
     function  valid_for_formal_const(p : tnode; report_errors: boolean) : boolean;
     function  valid_for_var(p:tnode; report_errors: boolean):boolean;
     function  valid_for_assignment(p:tnode; report_errors: boolean):boolean;
@@ -1943,6 +1944,13 @@ implementation
       end;
 
 
+    function  valid_for_formal_constref(p : tnode; report_errors: boolean) : boolean;
+      begin
+        valid_for_formal_constref:=(p.resultdef.typ=formaldef) or
+          valid_for_assign(p,[valid_void,valid_range],report_errors);
+      end;
+
+
     function  valid_for_formal_const(p : tnode; report_errors: boolean) : boolean;
       begin
         valid_for_formal_const:=(p.resultdef.typ=formaldef) or

+ 5 - 1
compiler/ncal.pas

@@ -1321,12 +1321,16 @@ implementation
 
                      case parasym.varspez of
                        vs_var,
-                       vs_constref,
                        vs_out :
                          begin
                            if not valid_for_formal_var(left,true) then
                             CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
                          end;
+                       vs_constref:
+                         begin
+                           if not valid_for_formal_constref(left,true) then
+                            CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
+                         end;
                        vs_const :
                          begin
                            if not valid_for_formal_const(left,true) then

+ 27 - 0
tests/tbs/tb0656.pp

@@ -0,0 +1,27 @@
+{ %NORUN }
+
+program tb0656;
+
+{$mode objfpc}
+
+procedure Test1(const aArg);
+begin
+end;
+
+procedure Test2(const aArg);
+begin
+  Test1(aArg);
+end;
+
+procedure Test3(constref aArg);
+begin
+end;
+
+procedure Test4(constref aArg);
+begin
+  Test3(aArg);
+end;
+
+begin
+
+end.