aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/cc/parser+module.test.testscript10
-rw-r--r--libbuild2/cc/parser.cxx18
-rw-r--r--libbuild2/cc/parser.hxx8
3 files changed, 22 insertions, 14 deletions
diff --git a/libbuild2/cc/parser+module.test.testscript b/libbuild2/cc/parser+module.test.testscript
index 91cbe45..6935f5e 100644
--- a/libbuild2/cc/parser+module.test.testscript
+++ b/libbuild2/cc/parser+module.test.testscript
@@ -59,6 +59,16 @@ import foo:part;
import foo:part.sub;
EOO
+: import-part-from-part
+:
+$* <<EOI >>EOO
+module foo:part;
+import :part.sub;
+EOI
+module foo:part;
+import foo:part.sub;
+EOO
+
: export-imported
:
$* <<EOI >>EOO
diff --git a/libbuild2/cc/parser.cxx b/libbuild2/cc/parser.cxx
index 61d62b7..dc5093f 100644
--- a/libbuild2/cc/parser.cxx
+++ b/libbuild2/cc/parser.cxx
@@ -195,7 +195,7 @@ namespace build2
if (!u_->module_info.name.empty ())
fail (l) << "multiple module declarations";
- u_->type =np.second
+ u_->type = np.second
? (ex ? unit_type::module_intf_part : unit_type::module_impl_part)
: (ex ? unit_type::module_intf : unit_type::module_impl);
u_->module_info.name = move (np.first);
@@ -226,22 +226,28 @@ namespace build2
}
case type::colon:
{
+ // Add the module name to the partition so that code that doesn't
+ // need to distinguish between different kinds of imports doesn't
+ // have to.
+ //
+ // Note that if this itself is a partition, then we need to strip
+ // the partition part from the module name.
+ //
switch (u_->type)
{
case unit_type::module_intf:
case unit_type::module_impl:
+ un = u_->module_info.name;
+ break;
case unit_type::module_intf_part:
case unit_type::module_impl_part:
+ un.assign (u_->module_info.name, 0, u_->module_info.name.find (':'));
break;
default:
fail (t) << "partition importation out of module purview";
}
- // Add the module name to the partition so that code that doesn't
- // need to distinguish beetween different kinds of imports doesn't
- // have to.
- //
- un = u_->module_info.name + parse_module_part (t);
+ parse_module_part (t, un);
ut = import_type::module_part;
break;
}
diff --git a/libbuild2/cc/parser.hxx b/libbuild2/cc/parser.hxx
index a1f1e57..1fbf1a3 100644
--- a/libbuild2/cc/parser.hxx
+++ b/libbuild2/cc/parser.hxx
@@ -44,14 +44,6 @@ namespace build2
pair<string, bool>
parse_module_name (token&, bool);
- string
- parse_module_part (token& t)
- {
- string n;
- parse_module_part (t, n);
- return n;
- }
-
void
parse_module_part (token&, string&);