MPS issue job004057

TitleWarning pragmas are not localised around the bad cases
Statusopen
Prioritynice
Assigned userGareth Rees
OrganizationRavenbrook
DescriptionIn Microsoft Visual C we use

     #pragma warning(disable: 4127)

(see config.h) to suppress the warning "conditional expression is constant" from the MPS_END macro. But this may also suppress valuable warnings elsewhere in the code.
AnalysisMicrosoft Visual C provides the __pragma keyword [1] for localizing a pragma in the output of a macro. So in this case we could write:

    #define MPS_END \
        __pragma(warning(push)) \
        __pragma(warning(disable:4127)) \
        } while (0) \
        __pragma(warning(pop))

except with suitable macros instead of __pragma so that this works on all our supported compilers. (But this will lead to another #if in mps.h so maybe it's not worth it.)
How foundinspection
Evidence[1] https://msdn.microsoft.com/en-us/library/d9x1s805.aspx#Anchor_3
Created byGareth Rees
Created on2017-03-04 12:38:21
Last modified byGareth Rees
Last modified on2017-03-04 13:23:15
History2017-03-04 GDR Created.