aboutsummaryrefslogtreecommitdiff
path: root/build2/test
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-01-02 14:28:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-01-02 14:28:10 +0200
commit8d743ac19a1b0c15deccfb14525eaeef56b4135b (patch)
treea6ef7627068939f3de8f09c14d06ae67c313a3ab /build2/test
parentaed0c46abaebd54e2df3777aaabf461c877012f7 (diff)
Fix few undefined behavior (ubsan) bugs
Diffstat (limited to 'build2/test')
-rw-r--r--build2/test/script/script.cxx6
-rw-r--r--build2/test/script/script.hxx8
2 files changed, 7 insertions, 7 deletions
diff --git a/build2/test/script/script.cxx b/build2/test/script/script.cxx
index 5a9ad3c..99ace23 100644
--- a/build2/test/script/script.cxx
+++ b/build2/test/script/script.cxx
@@ -435,9 +435,9 @@ namespace build2
// scope
//
scope::
- scope (const string& id, scope* p)
+ scope (const string& id, scope* p, script* r)
: parent (p),
- root (p != nullptr ? p->root : static_cast<script*> (this)),
+ root (r),
vars (false /* global */),
id_path (cast<path> (assign (root->id_var) = path ())),
wd_path (cast<dir_path> (assign (root->wd_var) = dir_path ()))
@@ -528,7 +528,7 @@ namespace build2
//
script::
script (const target& tt, const testscript& st, const dir_path& rwd)
- : group (st.name == "testscript" ? string () : st.name),
+ : group (st.name == "testscript" ? string () : st.name, this),
test_target (tt),
script_target (st)
{
diff --git a/build2/test/script/script.hxx b/build2/test/script/script.hxx
index e76d0ba..c511f01 100644
--- a/build2/test/script/script.hxx
+++ b/build2/test/script/script.hxx
@@ -427,7 +427,7 @@ namespace build2
~scope () = default;
protected:
- scope (const string& id, scope* parent);
+ scope (const string& id, scope* parent, script* root);
// Pre-parse data.
//
@@ -452,10 +452,10 @@ namespace build2
vector<unique_ptr<scope>> scopes;
public:
- group (const string& id, group& p): scope (id, &p) {}
+ group (const string& id, group& p): scope (id, &p, p.root) {}
protected:
- group (const string& id): scope (id, nullptr) {} // For root.
+ group (const string& id, script* r): scope (id, nullptr, r) {}
// Pre-parse data.
//
@@ -486,7 +486,7 @@ namespace build2
class test: public scope
{
public:
- test (const string& id, group& p): scope (id, &p) {}
+ test (const string& id, group& p): scope (id, &p, p.root) {}
// Pre-parse data.
//