From 45f7466bee41e59dc1e1d91c2ce97f34420c1931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Tue, 17 Nov 2026 14:45:47 +0100 Subject: [PATCH] Drop allow flags from model annotations --warnNonStandardModelica reports non-standard Modelica unless --allowNonStandardModelica allows it. Some models set that flag in their __OpenModelica_commandLineOptions annotation (IDEAS LIDEAS.Validation), and omc applies the annotation during the translation. Thus these models give no warning and are not marked invalid. If --warnNonStandardModelica is in the commands, testmodel.py now sets --ignoreCommandLineOptionsAnnotation and applies the other flags of the annotation itself. The .err file tells which flags it used. See #426. Assisted-by: Claude Opus 5.5 --- testmodel.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/testmodel.py b/testmodel.py index 9305429..d2d2b35 100755 --- a/testmodel.py +++ b/testmodel.py @@ -734,6 +734,7 @@ def wasmJitAcceptsFlag(flagVal): commandLineOptionsRe = re.compile(r'__OpenModelica_commandLineOptions\s*=\s*\\?"([^"\\]*)') daeModeRe = re.compile(r'(?:^|[\s"])(?:--|\+)daeMode(?:=(\w*))?(?![\w=])', re.IGNORECASE) +allowNonStandardRe = re.compile(r'^(?:--|-|\+)allowNonStandardModelica(?:=|$)') def modelCommandLineOptions(): """The flags the model's __OpenModelica_commandLineOptions annotation sets. @@ -816,6 +817,18 @@ def simulateCmd(resimulate): if emit_protected and (conf.get("fmi") or useWasmFmu): sendExpressionOldOrNew('setCommandLineOptions("--fmiFilter=internal")') +# --warnNonStandardModelica reports non-standard Modelica unless the model +# allows it itself, so the annotation is applied here without that flag. +if any("--warnNonStandardModelica" in str(c) for c in conf["customCommands"]): + annotationFlags = modelCommandLineOptions().split(" ") + keptFlags = [f for f in annotationFlags if f and not allowNonStandardRe.match(f)] + if len(keptFlags) < len([f for f in annotationFlags if f]): + with open(errFile, 'a+') as fp: + fp.write("Ignoring --allowNonStandardModelica in the __OpenModelica_commandLineOptions annotation; using: %s\n" % (" ".join(keptFlags) or "no flags")) + sendExpressionOldOrNew('setCommandLineOptions("--ignoreCommandLineOptionsAnnotation=true")') + if keptFlags: + sendExpressionOldOrNew('setCommandLineOptions("%s")' % " ".join(keptFlags)) + start=monotonic() timeout = conf["ulimitOmc"] # If the command has to be killed there is no way to tell which phase it was in,