aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-08-30 10:03:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-08-30 10:03:30 +0200
commitc76736eb1dde2fe5a8ae344dca2b018c79bdc218 (patch)
tree2d8c0bb2c8412289c0c8cc500906fea374c28d48
parent9f92d0b8d5c1e7d4976396ca26e677a89400ec90 (diff)
Handle missing export directive in export stub
If none were executed, then we assume the requested target is not exported.
-rw-r--r--build2/file.cxx13
-rw-r--r--build2/parser.cxx3
2 files changed, 14 insertions, 2 deletions
diff --git a/build2/file.cxx b/build2/file.cxx
index 728de64..05527f3 100644
--- a/build2/file.cxx
+++ b/build2/file.cxx
@@ -1370,7 +1370,7 @@ namespace build2
value& v (ts.assign (var_import_target));
if (!target.empty ()) // Otherwise leave NULL.
- v = move (target);
+ v = target; // Can't move (need for diagnostics below).
}
// Load the export stub. Note that it is loaded in the context
@@ -1391,7 +1391,16 @@ namespace build2
// name?
//
parser p;
- return p.parse_export_stub (ifs, es, iroot, ts);
+ names v (p.parse_export_stub (ifs, es, iroot, ts));
+
+ // If there were no export directive executed in an export stub, assume
+ // the target is not exported.
+ //
+ if (v.empty () && !target.empty ())
+ fail (loc) << "target " << target << " is not exported by project "
+ << proj;
+
+ return v;
}
catch (const io_error& e)
{
diff --git a/build2/parser.cxx b/build2/parser.cxx
index 6d025a6..1dd49b6 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -1509,6 +1509,9 @@ namespace build2
export_value_ = move (rhs).as<names> ();
+ if (export_value_.empty ())
+ fail (l) << "empty value in export";
+
if (tt == type::newline)
next (t, tt);
else if (tt != type::eos)