aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-07-20 10:29:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-07-20 10:29:14 +0200
commit446d4f91b38bcf2f12f645389e10b443c02c2a00 (patch)
treed06987010a9f08f05dc58718b8b5eaf740ec0445 /libbuild2/parser.cxx
parentc6c8d0be6fd99b2d8ac32c23d1a4141cdbdcd107 (diff)
Adjust conditional dependency declaration warning logic
Now instead of ignoring imported stuff (which turned out to be racy), we only consider conditions up to the include boundary. The thinking here is that an included (but not sourced) buildfile is a standalone entity (e.g., imported project but also could be just a side-included buildfile). Note that unfortunately we will still be issuing warnings in imported projects since there is no straightforward way to know what is being distributed and what is not while parsing.
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx18
1 files changed, 13 insertions, 5 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 84b6366..fd7c10e 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -247,7 +247,6 @@ namespace build2
{
pre_parse_ = false;
attributes_.clear ();
- imported_ = false;
condition_ = nullopt;
default_target_ = nullptr;
peeked_ = false;
@@ -2372,9 +2371,7 @@ namespace build2
// Diagnose conditional prerequisites. Note that we want to diagnose this
// even if pns is empty (think empty variable expansion; the literal "no
- // prerequisites" case is handled elsewhere). We also want to omit this
- // check for imported buildfiles (export stub can reasonably wrap loading
- // of a buildfile in a condition).
+ // prerequisites" case is handled elsewhere).
//
// @@ TMP For now we only do it during the dist meta-operation. In the
// future we should tighten this to any meta-operation provided
@@ -2385,7 +2382,6 @@ namespace build2
// rewrite (cli.cxx{} is not always registered).
//
if (condition_ &&
- !imported_ &&
ctx->current_mif != nullptr &&
ctx->current_mif->id == dist_id)
{
@@ -2918,6 +2914,18 @@ namespace build2
continue;
}
+ // Clear/restore if/switch location.
+ //
+ // We do it here but not in parse_source since the included buildfile is
+ // in a sense expected to be a standalone entity (think a file included
+ // from an export stub).
+ //
+ auto g = make_guard ([this, old = condition_] () mutable
+ {
+ condition_ = old;
+ });
+ condition_ = nullopt;
+
try
{
ifdstream ifs (p);