From d1663e509e8cc77a8fbb8345bb1fbccacacf2429 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Mar 2020 07:35:40 +0200 Subject: Diagnose unnamed project in version module --- libbuild2/version/init.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libbuild2/version') diff --git a/libbuild2/version/init.cxx b/libbuild2/version/init.cxx index c8e8559..135f2db 100644 --- a/libbuild2/version/init.cxx +++ b/libbuild2/version/init.cxx @@ -68,16 +68,19 @@ namespace build2 { if (nv.name == "name") { - auto& pn (cast (rs.vars[ctx.var_project])); + auto* pn (cast_null (rs.vars[ctx.var_project])); - if (nv.value != pn.string ()) + if (pn == nullptr) + fail (l) << "version module loaded in unnamed project"; + + if (nv.value != pn->string ()) { path bf (rs.src_path () / rs.root_extra->bootstrap_file); location ml (f, nv.value_line, nv.value_column); location bl (bf); fail (ml) << "package name " << nv.value << " does not match " - << "build system project name " << pn << + << "build system project name " << *pn << info (bl) << "build system project name specified here"; } } -- cgit v1.1