Parcourir la source

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 il y a 9 ans
Parent
commit
56ae2d34b2
1 fichiers modifiés avec 6 ajouts et 3 suppressions
  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