aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eval.cc3
-rw-r--r--symtab.cc9
-rw-r--r--symtab.h2
3 files changed, 9 insertions, 5 deletions
diff --git a/eval.cc b/eval.cc
index 6322fc1..bc27af9 100644
--- a/eval.cc
+++ b/eval.cc
@@ -101,7 +101,8 @@ void Evaluator::EvalAssign(const AssignStmt* stmt) {
Var* rhs = EvalRHS(lhs, stmt->rhs, stmt->orig_rhs, stmt->op,
stmt->directive == AssignDirective::OVERRIDE);
if (rhs)
- lhs.SetGlobalVar(rhs);
+ lhs.SetGlobalVar(rhs,
+ stmt->directive == AssignDirective::OVERRIDE);
}
void Evaluator::EvalRule(const RuleStmt* stmt) {
diff --git a/symtab.cc b/symtab.cc
index fb81bfe..edb6752 100644
--- a/symtab.cc
+++ b/symtab.cc
@@ -18,6 +18,8 @@
#include "symtab.h"
+#include <iostream>
+
#ifdef ENABLE_TID_CHECK
#include <pthread.h>
#endif
@@ -59,13 +61,14 @@ Var* Symbol::GetGlobalVar() const {
return v;
}
-void Symbol::SetGlobalVar(Var* v) const {
+void Symbol::SetGlobalVar(Var* v, bool is_override) const {
if (static_cast<size_t>(v_) >= g_symbol_data.size()) {
g_symbol_data.resize(v_ + 1);
}
Var* orig = g_symbol_data[v_].gv;
- if (orig->Origin() == VarOrigin::OVERRIDE ||
- orig->Origin() == VarOrigin::ENVIRONMENT_OVERRIDE) {
+ if (!is_override &&
+ (orig->Origin() == VarOrigin::OVERRIDE ||
+ orig->Origin() == VarOrigin::ENVIRONMENT_OVERRIDE)) {
return;
}
if (orig->Origin() == VarOrigin::AUTOMATIC) {
diff --git a/symtab.h b/symtab.h
index d1de4e1..e7e71d5 100644
--- a/symtab.h
+++ b/symtab.h
@@ -56,7 +56,7 @@ class Symbol {
bool IsValid() const { return v_ >= 0; }
Var* GetGlobalVar() const;
- void SetGlobalVar(Var* v) const;
+ void SetGlobalVar(Var* v, bool is_override = false) const;
private:
explicit Symbol(int v);