aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-12-17 10:27:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-12-17 10:27:36 +0200
commitf9d759160eef1ca870edcbb9b87caa23f0c93a43 (patch)
treec3e38f62491c8d4b891b50dd62144d25a5db6684
parent8065636673e85704f5aab3ce3674dea729cd2a86 (diff)
Diagnose C++ source/output target type mismatch (mxx{} vs cxx{})
-rw-r--r--build2/cc/compile.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx
index 3b60a5b..9de037e 100644
--- a/build2/cc/compile.cxx
+++ b/build2/cc/compile.cxx
@@ -918,6 +918,28 @@ namespace build2
break;
}
+ // Make sure the translation unit type matches the resulting target
+ // type.
+ //
+ switch (tu.type ())
+ {
+ case translation_type::plain:
+ case translation_type::module_impl:
+ {
+ if (mod)
+ fail << "translation unit " << src << " is not a module interface" <<
+ info << "consider using " << x_src.name << "{} instead";
+ break;
+ }
+ case translation_type::module_iface:
+ {
+ if (!mod)
+ fail << "translation unit " << src << " is a module interface" <<
+ info << "consider using " << x_mod->name << "{} instead";
+ break;
+ }
+ }
+
md.type = tu.type ();
// Extract the module dependency information in addition to header