diff options
Diffstat (limited to 'libbuild2/build')
-rw-r--r-- | libbuild2/build/script/parser+diag.test.testscript | 18 | ||||
-rw-r--r-- | libbuild2/build/script/parser.cxx | 13 | ||||
-rw-r--r-- | libbuild2/build/script/parser.hxx | 4 |
3 files changed, 22 insertions, 13 deletions
diff --git a/libbuild2/build/script/parser+diag.test.testscript b/libbuild2/build/script/parser+diag.test.testscript index a720fe2..504c9a4 100644 --- a/libbuild2/build/script/parser+diag.test.testscript +++ b/libbuild2/build/script/parser+diag.test.testscript @@ -19,6 +19,14 @@ $* <<EOI >>EOO name: echo EOO +: name-operation +: +$* <<EOI >>EOO + a = 'b' + EOI + name: update + EOO + : preamble : { @@ -141,16 +149,6 @@ $* <<EOI >>EOO info: consider specifying it explicitly with the 'diag' recipe attribute info: or provide custom low-verbosity diagnostics with the 'diag' builtin EOE - - : none - : - $* <<EOI 2>>EOE != 0 - a = 'b' - EOI - buildfile:11:1: error: unable to deduce low-verbosity script diagnostics name - info: consider specifying it explicitly with the 'diag' recipe attribute - info: or provide custom low-verbosity diagnostics with the 'diag' builtin - EOE } : inside-if diff --git a/libbuild2/build/script/parser.cxx b/libbuild2/build/script/parser.cxx index 5dd9179..df0a419 100644 --- a/libbuild2/build/script/parser.cxx +++ b/libbuild2/build/script/parser.cxx @@ -102,15 +102,22 @@ namespace build2 info << "consider using 'depdb' builtin to track its value " << "changes"; - // Diagnose absent/ambigous script name. + // Diagnose absent/ambiguous script name. But try to deduce an absent + // name from the script operation first. // { diag_record dr; if (!diag_name_ && diag_preamble_.empty ()) { - dr << fail (s.start_loc) - << "unable to deduce low-verbosity script diagnostics name"; + if (as.size () == 1) + { + diag_name_ = make_pair (ctx->operation_table[as[0].operation ()], + location ()); + } + else + dr << fail (s.start_loc) + << "unable to deduce low-verbosity script diagnostics name"; } else if (diag_name2_) { diff --git a/libbuild2/build/script/parser.hxx b/libbuild2/build/script/parser.hxx index 3121320..70e24aa 100644 --- a/libbuild2/build/script/parser.hxx +++ b/libbuild2/build/script/parser.hxx @@ -311,6 +311,10 @@ namespace build2 // builtin after the script name or after another diag builtin) is // reported as ambiguity. // + // If no script name is deduced by the end of pre-parsing and the + // script is used for a single operation, then use this operation's + // name as a script name. + // // At the end of pre-parsing either diag_name_ is present or // diag_preamble_ is not empty (but not both). // |