Prechádzať zdrojové kódy

Fix for Mantis #26278.

pbase.pas:
  + add an overload for identifier_not_found for which the file position can be supplied
pexpr.pas, factor_read_id:
  * store the file position before reading the identiifer token
  * use the new identiifer_not_found overload to explicitely set the file position
  * set the file position of the created node

git-svn-id: trunk@27947 -
svenbarth 11 rokov pred
rodič
commit
c6496f8ec5
2 zmenil súbory, kde vykonal 20 pridanie a 1 odobranie
  1. 13 0
      compiler/pbase.pas
  2. 7 1
      compiler/pexpr.pas

+ 13 - 0
compiler/pbase.pas

@@ -65,6 +65,7 @@ interface
        parse_generic : boolean;
        parse_generic : boolean;
 
 
     procedure identifier_not_found(const s:string);
     procedure identifier_not_found(const s:string);
+    procedure identifier_not_found(const s:string;const filepos:tfileposinfo);
 
 
 {    function tokenstring(i : ttoken):string;}
 {    function tokenstring(i : ttoken):string;}
 
 
@@ -118,6 +119,18 @@ implementation
        end;
        end;
 
 
 
 
+     procedure identifier_not_found(const s:string;const filepos:tfileposinfo);
+       begin
+         MessagePos1(filepos,sym_e_id_not_found,s);
+         { show a fatal that you need -S2 or -Sd, but only
+           if we just parsed the a token that has m_class }
+         if not(m_class in current_settings.modeswitches) and
+            (Upper(s)=pattern) and
+            (m_class in tokeninfo^[idtoken].keyword) then
+           MessagePos(filepos,parser_f_need_objfpc_or_delphi_mode);
+       end;
+
+
     { consumes token i, write error if token is different }
     { consumes token i, write error if token is different }
     procedure consume(i : ttoken);
     procedure consume(i : ttoken);
       begin
       begin

+ 7 - 1
compiler/pexpr.pas

@@ -2426,6 +2426,7 @@ implementation
            callflags: tcallnodeflags;
            callflags: tcallnodeflags;
            t : ttoken;
            t : ttoken;
            unit_found : boolean;
            unit_found : boolean;
+           tokenpos: tfileposinfo;
          begin
          begin
            { allow post fix operators }
            { allow post fix operators }
            again:=true;
            again:=true;
@@ -2448,6 +2449,8 @@ implementation
                unit_found:=try_consume_unitsym(srsym,srsymtable,t,true);
                unit_found:=try_consume_unitsym(srsym,srsymtable,t,true);
                storedpattern:=pattern;
                storedpattern:=pattern;
                orgstoredpattern:=orgpattern;
                orgstoredpattern:=orgpattern;
+               { store the position of the token before consuming it }
+               tokenpos:=current_filepos;
                consume(t);
                consume(t);
                { named parameter support }
                { named parameter support }
                found_arg_name:=false;
                found_arg_name:=false;
@@ -2508,7 +2511,7 @@ implementation
                      end
                      end
                    else
                    else
                      begin
                      begin
-                       identifier_not_found(orgstoredpattern);
+                       identifier_not_found(orgstoredpattern,tokenpos);
                        srsym:=generrorsym;
                        srsym:=generrorsym;
                        srsymtable:=nil;
                        srsymtable:=nil;
                      end;
                      end;
@@ -2761,6 +2764,9 @@ implementation
                     Message(parser_e_illegal_expression);
                     Message(parser_e_illegal_expression);
                   end;
                   end;
               end; { end case }
               end; { end case }
+
+              if p1.nodetype<>errorn then
+                p1.fileinfo:=tokenpos;
             end;
             end;
          end;
          end;