소스 검색

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
                  generic type as its argument. As we don't know certain
                  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
                  Message(parser_e_illegal_expression);
                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:
                    begin
-                     hp:=cconstsym.create_ord(orgname,constord,0,p.resultdef);
+                     hp:=cconstsym.create_ord(orgname,constord,8,p.resultdef);
                    end;
                  { add other cases here if necessary }
                  else