aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/variable.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-03-18 10:52:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-03-18 10:52:48 +0200
commit14b34a239fa23e1a28519ab87f450c0a440d4f85 (patch)
tree740db344520d93279cdc4a5f686ef339600e152f /libbuild2/variable.cxx
parent7d0c4c5ab6760e4487230f9eda87c352609be553 (diff)
Cleanup variable type/visibility/overridability logic
Diffstat (limited to 'libbuild2/variable.cxx')
-rw-r--r--libbuild2/variable.cxx34
1 files changed, 17 insertions, 17 deletions
diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx
index f1c5515..48fcf40 100644
--- a/libbuild2/variable.cxx
+++ b/libbuild2/variable.cxx
@@ -1143,7 +1143,7 @@ namespace build2
// Check overridability (all overrides, if any, should already have
// been entered; see context ctor for details).
//
- if (var.overrides != nullptr && (o == nullptr || !*o))
+ if (o != nullptr && var.overrides != nullptr && !*o)
fail << "variable " << var.name << " cannot be overridden";
bool ut (t != nullptr && var.type != t);
@@ -1285,25 +1285,23 @@ namespace build2
var.aliases = &var;
else // Note: overridden variable will always exist.
{
- if (pt != nullptr || pv != nullptr || po != nullptr)
+ // This is tricky: if the pattern does not require a match, then we
+ // should re-merge it with values that came from the variable.
+ //
+ bool vo;
+ if (pa != nullptr && !pa->match)
{
- // This is tricky: if the pattern does not require a match, then we
- // should re-merge it with values that came from the variable.
- //
- bool vo;
- if (pa != nullptr && !pa->match)
- {
- pt = t != nullptr ? t : var.type;
- pv = v != nullptr ? v : &var.visibility;
- po = o != nullptr ? o : &(vo = (var.overrides != nullptr));
-
- merge_pattern (*pa, pt, pv, po);
- }
+ pt = t != nullptr ? t : var.type;
+ pv = v != nullptr ? v : &var.visibility;
+ po = o != nullptr ? o : &(vo = true);
- update (var, pt, pv, po); // Not changing the key.
+ merge_pattern (*pa, pt, pv, po);
}
- else if (var.overrides != nullptr)
- fail << "variable " << var << " cannot be overridden";
+
+ if (po == nullptr) // NULL overridable falls back to false.
+ po = &(vo = false);
+
+ update (var, pt, pv, po); // Not changing the key.
}
return var;
@@ -1320,6 +1318,8 @@ namespace build2
nullptr /* override */,
false /* pattern */));
+ assert (a.overrides == nullptr);
+
if (a.aliases == &a) // Not aliased yet.
{
a.aliases = var.aliases;