From f9d759160eef1ca870edcbb9b87caa23f0c93a43 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 17 Dec 2017 10:27:36 +0200 Subject: Diagnose C++ source/output target type mismatch (mxx{} vs cxx{}) --- build2/cc/compile.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'build2/cc/compile.cxx') 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 -- cgit v1.1