diff options
| author | Dan Willemsen <dwillemsen@google.com> | 2018-09-15 12:57:42 -0700 |
|---|---|---|
| committer | Dan Willemsen <dwillemsen@google.com> | 2018-09-15 13:02:06 -0700 |
| commit | cf01530228bb67bf61dd7386a3eb33c1bfe1bb35 (patch) | |
| tree | 4ea5ac8d34e4348d555d8900e2bd26336e76e8a5 | |
| parent | 1584536cf2584c2e18cd67f2dd8ddcc35e68140f (diff) | |
| download | platform_build_kati-cf01530228bb67bf61dd7386a3eb33c1bfe1bb35.tar.gz platform_build_kati-cf01530228bb67bf61dd7386a3eb33c1bfe1bb35.tar.bz2 platform_build_kati-cf01530228bb67bf61dd7386a3eb33c1bfe1bb35.zip | |
Fix deprecate/obsolete vars in ifdef/call
We hadn't been checking variables that were used in ifdef/ifndef or
$(call) to see if they were deprecated.
Change-Id: I097dbfb081a703ec38d1f00473d5e1095100f483
| -rw-r--r-- | eval.cc | 1 | ||||
| -rw-r--r-- | func.cc | 7 | ||||
| -rw-r--r-- | testcase/deprecated_var.mk | 36 |
3 files changed, 30 insertions, 14 deletions
@@ -373,6 +373,7 @@ void Evaluator::EvalIf(const IfStmt* stmt) { if (lhs.str().find_first_of(" \t") != string::npos) Error("*** invalid syntax in conditional."); Var* v = LookupVarInCurrentScope(lhs); + v->Used(this, lhs); is_true = (v->String().empty() == (stmt->op == CondOp::IFNDEF)); break; } @@ -599,11 +599,12 @@ void CallFunc(const vector<Value*>& args, Evaluator* ev, string* s) { ev->CheckStack(); const string&& func_name_buf = args[0]->Eval(ev); - const StringPiece func_name = TrimSpace(func_name_buf); - Var* func = ev->LookupVar(Intern(func_name)); + Symbol func_sym = Intern(TrimSpace(func_name_buf)); + Var* func = ev->LookupVar(func_sym); + func->Used(ev, func_sym); if (!func->IsDefined()) { KATI_WARN_LOC(ev->loc(), "*warning*: undefined user function: %s", - func_name.as_string().c_str()); + func_sym.c_str()); } vector<unique_ptr<SimpleVar>> av; for (size_t i = 1; i < args.size(); i++) { diff --git a/testcase/deprecated_var.mk b/testcase/deprecated_var.mk index 2cacbda..e0be521 100644 --- a/testcase/deprecated_var.mk +++ b/testcase/deprecated_var.mk @@ -4,14 +4,14 @@ A := test $(KATI_deprecated_var A B C D) -# Writing to an undefined deprecated variable +$(info Writing to an undefined deprecated variable) B := test ifndef KATI $(info Makefile:8: B has been deprecated.) endif -# Reading from deprecated variables (set before/after/never the deprecation func) -# Writing to an undefined deprecated variable +$(info Reading from deprecated variables - set before/after/never the deprecation func) +$(info Writing to an undefined deprecated variable) D := $(A)$(B)$(C) ifndef KATI $(info Makefile:15: A has been deprecated.) @@ -20,27 +20,27 @@ $(info Makefile:15: C has been deprecated.) $(info Makefile:15: D has been deprecated.) endif -# Writing to a reset deprecated variable +$(info Writing to a reset deprecated variable) D += test ifndef KATI $(info Makefile:24: D has been deprecated.) endif -# Using a custom message +$(info Using a custom message) $(KATI_deprecated_var E,Use X instead) E = $(C) ifndef KATI $(info Makefile:31: E has been deprecated. Use X instead.) endif -# Expanding a recursive variable with an embedded deprecated variable +$(info Expanding a recursive variable with an embedded deprecated variable) $(E) ifndef KATI $(info Makefile:37: E has been deprecated. Use X instead.) $(info Makefile:37: C has been deprecated.) endif -# All of the previous variable references have been basic SymRefs, now check VarRefs +$(info All of the previous variable references have been basic SymRefs, now check VarRefs) F = E G := $($(F)) ifndef KATI @@ -48,13 +48,13 @@ $(info Makefile:45: E has been deprecated. Use X instead.) $(info Makefile:45: C has been deprecated.) endif -# And check VarSubst +$(info And check VarSubst) G := $(C:%.o=%.c) ifndef KATI $(info Makefile:52: C has been deprecated.) endif -# Deprecated variable used in a rule-specific variable +$(info Deprecated variable used in a rule-specific variable) test: A := $(E) ifndef KATI $(info Makefile:58: E has been deprecated. Use X instead.) @@ -62,9 +62,23 @@ $(info Makefile:58: C has been deprecated.) # A hides the global A variable, so is not considered deprecated. endif -# Deprecated variable used in a rule +$(info Deprecated variable used as a macro) +A := $(call B) +ifndef KATI +$(info Makefile:66: B has been deprecated.) +$(info Makefile:66: A has been deprecated.) +endif + +$(info Deprecated variable used in an ifdef) +ifdef C +endif +ifndef KATI +$(info Makefile:73: C has been deprecated.) +endif + +$(info Deprecated variable used in a rule) test: echo $(C)Done ifndef KATI -$(info Makefile:67: C has been deprecated.) +$(info Makefile:81: C has been deprecated.) endif |
