Prechádzať zdrojové kódy

* fix for Mantis #37187: inside generics the constant code in pexpr does not handle all cases and thus current_procinfo needs to be checked as well
+ added test

git-svn-id: trunk@46218 -

svenbarth 5 rokov pred
rodič
commit
8770af84bd
3 zmenil súbory, kde vykonal 23 pridanie a 1 odobranie
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/ninl.pas
  3. 19 0
      tests/webtbs/tw37187.pp

+ 1 - 0
.gitattributes

@@ -18381,6 +18381,7 @@ tests/webtbs/tw37107.pp svneol=native#text/pascal
 tests/webtbs/tw37130.pp svneol=native#text/pascal
 tests/webtbs/tw37136.pp svneol=native#text/pascal
 tests/webtbs/tw37154.pp svneol=native#text/pascal
+tests/webtbs/tw37187.pp svneol=native#text/pascal
 tests/webtbs/tw3719.pp svneol=native#text/plain
 tests/webtbs/tw3721.pp svneol=native#text/plain
 tests/webtbs/tw37218.pp svneol=native#text/pascal

+ 3 - 1
compiler/ninl.pas

@@ -2970,9 +2970,11 @@ implementation
 
               in_sizeof_x:
                 begin
-                  { the constant evaluation of in_sizeof_x happens in pexpr where possible }
+                  { the constant evaluation of in_sizeof_x happens in pexpr where possible,
+                    though for generics it can reach here as well }
                   set_varstate(left,vs_read,[]);
                   if (left.resultdef.typ<>undefineddef) and
+                      assigned(current_procinfo) and
                       paramanager.push_high_param(vs_value,left.resultdef,current_procinfo.procdef.proccalloption) then
                    begin
                      { this should be an open array or array of const, both of

+ 19 - 0
tests/webtbs/tw37187.pp

@@ -0,0 +1,19 @@
+{ %NORUN }
+
+program tw37187;
+
+{$mode objfpc}
+
+type
+  generic TTest<T: class> = class
+    arr: array[0..SizeOf(T)] of Byte;
+  end;
+
+  generic TTest2<T: class> = class
+  public type
+    TTestT = specialize TTest<T>;
+  end;
+
+begin
+
+end.