aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/context.cxx2
-rw-r--r--build2/parser.cxx17
-rw-r--r--build2/variable.cxx14
3 files changed, 22 insertions, 11 deletions
diff --git a/build2/context.cxx b/build2/context.cxx
index 0357eb6..cbb2656 100644
--- a/build2/context.cxx
+++ b/build2/context.cxx
@@ -179,7 +179,7 @@ namespace build2
c == '%' ? variable_visibility::project :
variable_visibility::normal);
- const variable& var (vp.insert (n));
+ const variable& var (vp.insert (n, true)); // Allow overrides.
const char* k (tt == token_type::assign ? ".__override" :
tt == token_type::append ? ".__suffix" : ".__prefix");
diff --git a/build2/parser.cxx b/build2/parser.cxx
index 2ffd0cf..154c123 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -458,7 +458,8 @@ namespace build2
const variable& var (
var_pool.rw (*scope_).insert (
- parse_variable_name (move (pns), ploc)));
+ parse_variable_name (move (pns), ploc),
+ true)); // Allow overrides.
// Apply variable attributes.
//
@@ -727,7 +728,8 @@ namespace build2
{
const variable& var (
var_pool.rw (*scope_).insert (
- parse_variable_name (move (ns), nloc)));
+ parse_variable_name (move (ns), nloc),
+ true)); // Allow overrides.
// Apply variable attributes.
//
@@ -1054,7 +1056,7 @@ namespace build2
auto& vp (var_pool.rw (*scope_));
if (p != string::npos)
- var = &vp.insert (split (p));
+ var = &vp.insert (split (p), true); // Allow overrides.
//
// This could still be the 'foo =...' case.
//
@@ -1069,7 +1071,7 @@ namespace build2
(v[p = 0] == '=' ||
(n > 1 && v[0] == '+' && v[p = 1] == '=')))
{
- var = &vp.insert (move (t.value));
+ var = &vp.insert (move (t.value), true); // Allow overrides.
next (t, tt); // Get the peeked token.
split (p); // Returned name should be empty.
}
@@ -1593,7 +1595,10 @@ namespace build2
if (type != nullptr)
{
if (var.type == nullptr)
- var_pool.update (const_cast<variable&> (var), type);
+ {
+ const bool o (true); // Allow overrides.
+ var_pool.update (const_cast<variable&> (var), type, nullptr, &o);
+ }
else if (var.type != type)
fail (l) << "changing variable " << var << " type from "
<< var.type->name << " to " << type->name;
@@ -3502,7 +3507,7 @@ namespace build2
// Lookup.
//
- const auto& var (var_pool.rw (*scope_).insert (move (name)));
+ const auto& var (var_pool.rw (*scope_).insert (move (name), true));
return target_ != nullptr ? (*target_)[var] : (*scope_)[var];
// Undefined/NULL namespace variables are not allowed.
diff --git a/build2/variable.cxx b/build2/variable.cxx
index 78f7c04..48f3345 100644
--- a/build2/variable.cxx
+++ b/build2/variable.cxx
@@ -1003,7 +1003,14 @@ namespace build2
if (o == nullptr)
o = &*p.overridable;
else if (p.match)
- assert (*o == *p.overridable);
+ {
+ // Allow the pattern to restrict but not relax.
+ //
+ if (*o)
+ o = &*p.overridable;
+ else
+ assert (*o == *p.overridable);
+ }
}
}
@@ -1046,9 +1053,8 @@ namespace build2
{
if (t != nullptr || v != nullptr || o != nullptr)
update (r, t, v, o); // Not changing the key.
- else
- if (r.override != nullptr)
- fail << "variable " << r.name << " cannot be overridden";
+ else if (r.override != nullptr)
+ fail << "variable " << r.name << " cannot be overridden";
}
return r;