Explorar o código

pgenutil.pas, generate_specialization: set the correct module index, so that warnings, etc. that are generated for a type declaration are printed using the module where the generic came from (this is already done for method bodies, but not for declarations)

git-svn-id: trunk@21271 -
svenbarth %!s(int64=13) %!d(string=hai) anos
pai
achega
b3595893c8
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      compiler/pgenutil.pas

+ 10 - 0
compiler/pgenutil.pas

@@ -91,6 +91,8 @@ uses
         old_block_type: tblock_type;
         hashedid: thashedidstring;
         state : tspecializationstate;
+        hmodule : tmodule;
+        oldcurrent_filepos : tfileposinfo;
       begin
         { retrieve generic def that we are going to replace }
         genericdef:=tstoreddef(tt);
@@ -426,9 +428,17 @@ uses
 
                 if not assigned(genericdef.generictokenbuf) then
                   internalerror(200511171);
+                hmodule:=find_module_from_symtable(genericdef.owner);
+                if hmodule=nil then
+                  internalerror(2012051202);
+                oldcurrent_filepos:=current_filepos;
+                { use the index the module got from the current compilation process }
+                current_filepos.moduleindex:=hmodule.unit_index;
+                current_tokenpos:=current_filepos;
                 current_scanner.startreplaytokens(genericdef.generictokenbuf,
                   genericdef.change_endian);
                 read_named_type(tt,finalspecializename,genericdef,generictypelist,false);
+                current_filepos:=oldcurrent_filepos;
                 ttypesym(srsym).typedef:=tt;
                 tt.typesym:=srsym;