From 6b474fda6e13dcda28ec81482e74c64ea3b2c498 Mon Sep 17 00:00:00 2001 From: Thomas Helfer Date: Tue, 19 Mar 2024 14:33:19 +0100 Subject: [PATCH] Fix Issue #524 --- docs/web/release-notes-4.0.3.md | 4 ++++ mfront/src/BehaviourDSLCommon.cxx | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/web/release-notes-4.0.3.md b/docs/web/release-notes-4.0.3.md index dcf0a0413..bb2089992 100644 --- a/docs/web/release-notes-4.0.3.md +++ b/docs/web/release-notes-4.0.3.md @@ -19,6 +19,10 @@ eqnPrefixTemplate: "($$i$$)" # Issues fixed +## Issue 524: [mfront] prevent importing a model not implemented using the Model DSL in behaviors + +For more details, see + ## Issue 522: [mfront] Visual Studio 2022 compiler intrinsic type traits error C2139 For more details, see diff --git a/mfront/src/BehaviourDSLCommon.cxx b/mfront/src/BehaviourDSLCommon.cxx index 346d5af40..496d56ca5 100644 --- a/mfront/src/BehaviourDSLCommon.cxx +++ b/mfront/src/BehaviourDSLCommon.cxx @@ -883,9 +883,19 @@ namespace mfront { getLogStream() << "BehaviourDSLCommon::getModelDescription: " << "treating file '" << f << "'\n"; } + // + const auto path = SearchPathsHandler::search(f); + // a simple test to fix Issue #524 + const auto adsl = MFrontBase::getDSL(path); + if (adsl->getTargetType() != AbstractDSL::MODELDSL) { + this->throwRuntimeError("BehaviourDSLCommon::getModelDescription", + "error while treating file '" + f + + "'.\n" + "This file is not handled by the Model DSL"); + } + // const auto& global_options = GlobalDomainSpecificLanguageOptionsManager::get(); - const auto path = SearchPathsHandler::search(f); auto dsl = ModelDSL{tfel::utilities::merge( global_options.getModelDSLOptions(), this->buildDSLOptions(), true)}; // getting informations the source files