Ver Fonte

+ Reject object types without VMT as arguments of typeof(). Without this check, an undefined reference to VMT is generated which fails at the linking stage.

git-svn-id: trunk@21923 -
sergei há 13 anos atrás
pai
commit
684bf4fba2
4 ficheiros alterados com 309 adições e 300 exclusões
  1. 2 0
      compiler/msg/errore.msg
  2. 3 2
      compiler/msgidx.inc
  3. 300 298
      compiler/msgtxt.inc
  4. 4 0
      compiler/ninl.pas

+ 2 - 0
compiler/msg/errore.msg

@@ -1866,6 +1866,8 @@ type_e_interface_lower_visibility=04117_E_The interface method "$1" has a higher
 % warning that is disabled by default because such situations are common
 % practice, but it can be enabled in case you are concerned with keeping your
 % code compilable for the JVM target.
+type_e_typeof_requires_vmt=04118_E_TYPEOF can only be used on object types with VMT
+% Typeof() intrinsic returns pointer to VMT of its argument. It cannot be used on object types that do not have VMT.
 % \end{description}
 #
 # Symtable

+ 3 - 2
compiler/msgidx.inc

@@ -525,6 +525,7 @@ const
   type_e_no_managed_assign_generic_typecast=04115;
   type_w_interface_lower_visibility=04116;
   type_e_interface_lower_visibility=04117;
+  type_e_typeof_requires_vmt=04118;
   sym_e_id_not_found=05000;
   sym_f_internal_error_in_symtablestack=05001;
   sym_e_duplicate_id=05002;
@@ -944,9 +945,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 66002;
+  MsgTxtSize = 66059;
 
   MsgIdxMax : array[1..20] of longint=(
-    26,92,323,118,87,56,116,26,202,63,
+    26,92,323,119,87,56,116,26,202,63,
     53,20,1,1,1,1,1,1,1,1
   );

Diff do ficheiro suprimidas por serem muito extensas
+ 300 - 298
compiler/msgtxt.inc


+ 4 - 0
compiler/ninl.pas

@@ -2520,7 +2520,11 @@ implementation
                 begin
                   if target_info.system in systems_managed_vm then
                     message(parser_e_feature_unsupported_for_vm);
+                  typecheckpass(left);
                   set_varstate(left,vs_read,[]);
+                  if (left.resultdef.typ=objectdef) and
+                    not(oo_has_vmt in tobjectdef(left.resultdef).objectoptions) then
+                      message(type_e_typeof_requires_vmt);
                   resultdef:=voidpointertype;
                 end;
 

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff