aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
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);