MATLAB: R2016b Diagnostic Viewer incorrectly displays warning messages containing a newline character

simulink

We issue warning messages in .m files which are executed in the Simulink build process (via a customized target that is based on grt).
The messages are displayed in the Diagnostic Viewer.
If the warning message contains a newline character (\n) then the diagnostic viewer displays the message including line breaks, but it doesn’t present it as warning (i.e. orange line at left border is expected) but only as info message (i.e. with blue/gray line).  Other special characters work fine, and the same code executed with Simulink 2016a works fine.
The same code executed directly in the MATLAB console window also works, even with R2016b.
This is reproducible by adding any of these warnings to the ert_make_rtw_hook.m file or any m-file within the Simulink build process:
warning ('A:B', 'without line break results in correct display as warning');
warning ('A:B' ,'Should display as warning with line break \n but displays only as info with line break');
warning ('A:B' ,'Should display as warning with line break \n but displays only as info with line break. Hint from help (include more than one input argument like %d) has no effect.', 99);
Any similar use of the "warning" function produces the same result, e.g.:
warning('mywarn:noLineBreaks', 'without line break results in correct display as warning');
warning('mywarn:charLineBreak',['With character specification for line break' char(10) 'we also do not get a warning']);
warning('mywarn:nLineBreak','With newline specification for line break \n we also do not get a warning');
warning('mywarn:formatSpec','With format specification for line break %s we just get the character','\n');
warning('mywarn:formatSpec','With format specification for char(10) %s we also do not get a warning',char(10));

Best Answer

As a workaround, one can use the following syntax instead of using the "warning" function:
>> message = sprintf('With newline specification for line break \n we also do not get a warning');
>> sldiagviewer.reportWarning(message);