JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 28.0w AdaCore Inc
C and C++


PARSE.STDCPNAH : STDC #pragma Not Allowed Here

Summary

A STDC pragma is used in an invalid location, such as after statements or declarations in a block or outside the global scope. STDC pragmas may only appear between declarations in global scope or before any statements in a function body.

Properties

Class Name STDC #pragma Not Allowed Here
Significance style
Mnemonic PARSE.STDCPNAH
Categories None
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. However, warning instances of this class that are issued as parser errors (rather than parser warnings) will be discarded when using factory configuration settings. To prevent these instances from being discarded, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="STDC #pragma Not Allowed Here"
To disable checks for this warning class, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="STDC #pragma Not Allowed Here"

Example

int main(void)
{
    int x = 5;
    #pragma STDC FP_CONTRACT OFF  /* 'STDC #pragma Not Allowed Here' warning issued here */
    return x;
}

int contraction_fixed(void)
{
#pragma STDC FP_CONTRACT OFF /* ok: the pragma precedes declarations and statements in the block. */
    int x = 5;
    return x;
}

To reproduce this example, analyze it with the following configuration:

WARNING_FILTER += allow class="STDC #pragma Not Allowed Here"
# Enable the C99 STDC pragma rules so this pragma after a declaration
# reaches the placement check; xcc does not translate -std=c99.
EDG_FRONTEND_OPTIONS_PREPEND += --c99
gcc -c -std=c99 example.c

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

To report problems with this documentation, please visit https://support.adacore.com/csm.