Compiler attributes analyzed by Klocwork
The following table provides a list of compiler attributes supported by Klocwork issue analysis:
GNU attributes | Description |
---|---|
noreturn | A few standard library functions, such as abort and exit, cannot return. GCC knows this automatically. Some programs define their own functions that never return. You can declare them noreturn to let the compiler know this. |
nonnull (arg-index) | Specifies that some function parameters should be non-null pointers. |
format (archetype, string-index, first-to-check) | Specifies that a function takes printf, scanf, strftime or strfmon style arguments which should be type-checked against a format string. The parameter archetype determines how the format string is interpreted, and should be printf, scanf, strftime or strfmon. The parameter string-index specifies which argument is the format string argument (starting from 1), while first-to-check is the number of the first argument to check against the format string. For functions where the arguments are not available to be checked (such as vprintf), specify the third parameter as zero. In this case, the compiler only checks the format string for consistency. For strftime formats, the third parameter must be zero. Since non-static C++ methods have an implicit this argument, the arguments of such methods should be counted from two, not one, when giving values for string-index and first-to-check. |
format_arg (string-index) | Specifies that a function takes a format string for a printf, scanf, strftime or strfmon style function and modifies it (for example, to translate it into another language), so that the result can be passed to a printf, scanf, strftime or strfmon style function (with the remaining arguments to the format function the same as they would have been for the unmodified string) |
alias ("target") | Causes the declaration to be emitted as an alias for another symbol, which must be specified |
aligned (alignment) | Specifies a minimum alignment for the variable or structure field, measured in bytes |
packed | Specifies that a variable or structure field should have the smallest possible alignment--one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute |
MS attributes | Description |
noreturn | see the GNU noreturn attribute description |