From 924f9466f0219cab6ea5c52da9b5676c97f9cf5d Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 9 Jul 2021 15:52:00 +0000 Subject: [PATCH] * fix for Mantis #26760: apply patch by Ondrej Pokorny to ensure that units referenced by an "in"-clause are recompiled when they have been changed + added test (though due to the nature of the bug it needs to be interactive) git-svn-id: trunk@49587 - --- .gitattributes | 2 ++ compiler/fppu.pas | 32 +++++++++++++++++++++----------- tests/webtbs/tw26760.pp | 17 +++++++++++++++++ tests/webtbs/uw26760/uw26760.pp | 17 +++++++++++++++++ 4 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 tests/webtbs/tw26760.pp create mode 100644 tests/webtbs/uw26760/uw26760.pp diff --git a/.gitattributes b/.gitattributes index b3a2fe740b..2f39ca7f1e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18134,6 +18134,7 @@ tests/webtbs/tw2668.pp svneol=native#text/plain tests/webtbs/tw2669.pp svneol=native#text/plain tests/webtbs/tw26749.pp svneol=native#text/pascal tests/webtbs/tw2676.pp svneol=native#text/plain +tests/webtbs/tw26760.pp svneol=native#text/pascal tests/webtbs/tw26773.pp svneol=native#text/plain tests/webtbs/tw2678.pp svneol=native#text/plain tests/webtbs/tw26791.pp svneol=native#text/pascal @@ -19366,6 +19367,7 @@ tests/webtbs/uw25598.pp svneol=native#text/plain tests/webtbs/uw25610a.pp -text svneol=native#text/plain tests/webtbs/uw25610b.pp -text svneol=native#text/plain tests/webtbs/uw25814.pp svneol=native#text/plain +tests/webtbs/uw26760/uw26760.pp svneol=native#text/pascal tests/webtbs/uw26922a.pp svneol=native#text/pascal tests/webtbs/uw26922b.pp svneol=native#text/pascal tests/webtbs/uw2706a.pp svneol=native#text/plain diff --git a/compiler/fppu.pas b/compiler/fppu.pas index 397efe1fe5..004d257f46 100644 --- a/compiler/fppu.pas +++ b/compiler/fppu.pas @@ -538,7 +538,7 @@ var var fnd : boolean; - hs : TPathStr; + hs : TPathStr; nsitem : TCmdStrListItem; begin if shortname then @@ -1129,20 +1129,30 @@ var else begin { check the date of the source files: - 1 path of ppu - 2 path of main source - 3 current dir - 4 include/unit path } - Source_Time:=GetNamedFileTime(path+hs); + 1 path of sourcefn + 2 path of ppu + 3 path of main source + 4 current dir + 5 include/unit path } found:=false; - if Source_Time<>-1 then - hs:=path+hs + if sourcefn<>'' then + Source_Time:=GetNamedFileTime(sourcefn) + else + Source_Time:=-1; + if Source_Time<>-1 then + hs:=sourcefn else - if not(is_main) then begin - Source_Time:=GetNamedFileTime(main_dir+hs); + Source_Time:=GetNamedFileTime(path+hs); if Source_Time<>-1 then - hs:=main_dir+hs; + hs:=path+hs + else + if not(is_main) then + begin + Source_Time:=GetNamedFileTime(main_dir+hs); + if Source_Time<>-1 then + hs:=main_dir+hs; + end; end; if Source_Time=-1 then Source_Time:=GetNamedFileTime(hs); diff --git a/tests/webtbs/tw26760.pp b/tests/webtbs/tw26760.pp new file mode 100644 index 0000000000..43763138f2 --- /dev/null +++ b/tests/webtbs/tw26760.pp @@ -0,0 +1,17 @@ +{ %INTERACTIVE } + +{ Note: to test this, first compile this program, then change something inside + unit uw26760 and make sure that it's recompiled (e.g. either by checking + the compiler messages or by introducing a compile error) } + +program tw26760; + +{$mode objfpc}{$H+} + +uses + uw26760 in 'uw26760/uw26760.pp'; + +begin + Test; +end. + diff --git a/tests/webtbs/uw26760/uw26760.pp b/tests/webtbs/uw26760/uw26760.pp new file mode 100644 index 0000000000..23635be912 --- /dev/null +++ b/tests/webtbs/uw26760/uw26760.pp @@ -0,0 +1,17 @@ +unit uw26760; + +{$mode objfpc}{$H+} + +interface + +procedure Test; + +implementation + +procedure Test; +begin + Writeln('test'); a +end; + +end. +