Procházet zdrojové kódy

* perform real "exactness" checking for open array parameters

git-svn-id: trunk@9624 -
Jonas Maebe před 17 roky
rodič
revize
08ccb30e3b
3 změnil soubory, kde provedl 26 přidání a 7 odebrání
  1. 1 0
      .gitattributes
  2. 11 7
      compiler/defcmp.pas
  3. 14 0
      tests/tbf/tb0205.pp

+ 1 - 0
.gitattributes

@@ -6039,6 +6039,7 @@ tests/tbf/tb0202.pp svneol=native#text/plain
 tests/tbf/tb0203.pp svneol=native#text/plain
 tests/tbf/tb0204.pp svneol=native#text/plain
 tests/tbf/tb0204a.pp svneol=native#text/plain
+tests/tbf/tb0205.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

+ 11 - 7
compiler/defcmp.pas

@@ -705,7 +705,10 @@ implementation
                              { open array -> open array }
                              if is_open_array(def_from) and
                                 equal_defs(tarraydef(def_from).elementdef,tarraydef(def_to).elementdef) then
-                               eq:=te_equal
+                               if tarraydef(def_from).elementdef=tarraydef(def_to).elementdef then
+                                 eq:=te_exact
+                               else
+                                 eq:=te_equal
                             else
                              { array -> open array }
                              if not(cdo_parameter in cdoptions) and
@@ -1566,12 +1569,13 @@ implementation
               { check type }
               if eq=te_incompatible then
                 exit;
-              { open arrays can never match exactly, since you cannot define }
-              { a separate "open array" type -> we have to be able to        }
-              { consider those as exact when resolving forward definitions.  }
-              { The same goes for openstrings and array of const             }
-              if (is_open_array(currpara1.vardef) or
-                  is_array_of_const(currpara1.vardef) or
+              { open strings can never match exactly, since you cannot define }
+              { a separate "open string" type -> we have to be able to        }
+              { consider those as exact when resolving forward definitions.   }
+              { The same goes for array of const. Open arrays are handled     }
+              { already (if their element types match exactly, they are       }
+              { considered to be an exact match)                              }
+              if (is_array_of_const(currpara1.vardef) or
                   is_open_string(currpara1.vardef)) and
                  (eq=te_equal) and
                  (cpo_openequalisexact in cpoptions) then

+ 14 - 0
tests/tbf/tb0205.pp

@@ -0,0 +1,14 @@
+{ %fail }
+
+procedure test(a: array of longint); forward;
+
+type
+  tl = type longint;
+
+procedure test(a: array of tl);
+begin
+end;
+
+begin
+end.
+