浏览代码

Ensure that (Bit)SizeOf(GenericParameter) returns a sensible value in case of constants (which are evaluated at compile time unlike if occuring in code)

pdecl.pas, readconstant:
  * instead of 0 return 1 for SizeOf() and 8 for BitSizeOf() if the argument is a generic parameter

git-svn-id: trunk@33323 -
svenbarth 9 年之前
父节点
当前提交
56ae2d34b2
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      compiler/pdecl.pas

+ 6 - 3
compiler/pdecl.pas

@@ -159,14 +159,17 @@ implementation
                { this situation only happens if a intrinsic is parsed that has a
                { this situation only happens if a intrinsic is parsed that has a
                  generic type as its argument. As we don't know certain
                  generic type as its argument. As we don't know certain
                  information about the final type yet, we need to use safe
                  information about the final type yet, we need to use safe
-                 values (mostly 0) }
+                 values (mostly 0, except for (Bit)SizeOf()) }
                if not parse_generic then
                if not parse_generic then
                  Message(parser_e_illegal_expression);
                  Message(parser_e_illegal_expression);
                case tinlinenode(p).inlinenumber of
                case tinlinenode(p).inlinenumber of
-                 in_sizeof_x,
+                 in_sizeof_x:
+                   begin
+                     hp:=cconstsym.create_ord(orgname,constord,1,p.resultdef);
+                   end;
                  in_bitsizeof_x:
                  in_bitsizeof_x:
                    begin
                    begin
-                     hp:=cconstsym.create_ord(orgname,constord,0,p.resultdef);
+                     hp:=cconstsym.create_ord(orgname,constord,8,p.resultdef);
                    end;
                    end;
                  { add other cases here if necessary }
                  { add other cases here if necessary }
                  else
                  else