Compilation toolchain (Static Analysis)
Specify the compiler that you use to build your source code for static analysis
Description
The option with this name is available only in the Polyspace Platform (Polyspace Test) user interface. For the equivalent option in the standard Polyspace® user interface, see Compiler (-compiler)
.
Specify the compiler that you use to build your source code for static analysis. This
option applies to only static analysis. For dynamic testing, specify your build toolchain
using the option Compilation
toolchain (Testing)
(Polyspace Test).
Polyspace fully supports the most common compilers used to develop embedded
applications. See the list below. For these compilers, you can run static analysis simply
by specifying your compiler and target processor. For other compilers, specify
generic
as compiler name. If you face compilation errors,
explicitly define compiler-specific extensions to work around the errors.
Set Option
User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Build tab on the Target & Compiler node.
Command line and options file: Use the option -compiler
. See
Command-Line Information.
Why Use This Option
Polyspace uses this information to interpret syntax that is not part of the C/C++ Standard, but comes from language extensions.
For example, the option allows additional language keywords, such as
sfr
, sbit
, and bit
. If you
do not specify your compiler, these additional keywords can cause compilation errors
during Polyspace analysis.
During static analysis, Polyspace does not actually invoke your compiler for compilation. In particular:
You cannot specify compiler flags directly in the Polyspace analysis. To emulate your compiler flags, trace your build command or manually specify equivalent Polyspace analysis options. See Specify Target Environment and Compiler Behavior.
Code Prover has a linking policy that is stricter than regular compilers. For instance, if your compiler allows declaration mismatches with specific compiler options, you cannot emulate this linking policy in Code Prover. See Troubleshoot Compilation and Linking Errors (Polyspace Code Prover).
Settings
Default: generic
GCC Compilers
gnu3.4
Analysis allows GCC 3.4 syntax.
gnu4.6
Analysis allows GCC 4.6 syntax.
gnu4.7
Analysis allows GCC 4.7 syntax.
For unsupported GCC extensions, see Limitations.
gnu4.8
Analysis allows GCC 4.8 syntax.
For unsupported GCC extensions, see Limitations.
gnu4.9
Analysis allows GCC 4.9 syntax.
For unsupported GCC extensions, see Limitations.
gnu5.x
Analysis allows GCC 5.x syntax. For a list of available GCC 5.x releases, see GCC releases.
For unsupported GCC extensions, see Limitations.
gnu6.x
Analysis allows GCC 6.x syntax. For a list of available GCC 6.x releases, see GCC releases.
For unsupported GCC extensions, see Limitations.
gnu7.x
Analysis allows GCC 7.x syntax. For a list of available GCC 7.x releases, see GCC releases.
For unsupported GCC extensions, see Limitations.
gnu8.x
Analysis allows GCC 8.x syntax. For a list of available GCC 8.x releases, see GCC releases.
For unsupported GCC extensions, see Limitations.
gnu9.x
Analysis allows GCC 9.x syntax. For a list of available GCC 9.x releases, see GCC releases.
For unsupported GCC extensions, see Limitations.
gnu10.x
Analysis allows GCC 10.x syntax. For a list of available GCC 10.x releases, see GCC releases.
For unsupported GCC extensions, see Limitations.
gnu11.x
Analysis allows GCC 11.x syntax. For a list of available GCC 11.x releases, see GCC releases.
For unsupported GCC extensions, see Limitations.
gnu12.x
Analysis allows GCC 12.x syntax. For a list of available GCC 12.x releases, see GCC releases.
For unsupported GCC extensions, see Limitations.
Clang Compilers
clang3.x
Analysis allows Clang syntax for these versions:
3.5.0, 3.5.1, and 3.5.2
3.6.0, 3.6.1, and 3.6.2
3.7.0 and 3.7.1
3.8.0 and 3.8.1
3.9.0 and 3.9.1
clang4.x
Analysis allows Clang 4.0.0, and 4.0.1 syntax.
clang5.x
Analysis allows Clang 5.0.0, 5.0.1, and 5.0.2 syntax.
clang6.x
Analysis allows Clang 6.0.0 and 6.0.1 syntax.
clang7.x
Analysis allows Clang 7.0.0, 7.0.1, and 7.1.0 syntax.
clang8.x
Analysis allows Clang 8.0.0 and 8.0.1 syntax.
clang9.x
Analysis allows Clang 9.0.0 and 9.0.1 syntax.
clang10.x
Analysis allows Clang 10.0.0 and 10.0.1 syntax.
clang11.x
Analysis allows Clang 11.0.0, 11.0.1, and 11.1.0 syntax.
clang12.x
Analysis allows Clang 12.0.0 and 12.0.1 syntax.
clang13.x
Analysis allows Clang 13.0.0 and 13.0.1 syntax.
Visual Studio Compilers
visual9.0
Analysis allows Microsoft® Visual C++® 2008 syntax.
visual10.0
Analysis allows Microsoft Visual C++ 2010 syntax.
visual11.0
Analysis allows Microsoft Visual C++ 2012 syntax.
visual12.0
Analysis allows Microsoft Visual C++ 2013 syntax.
visual14.0
Analysis allows Microsoft Visual C++ 2015 syntax (supports Microsoft Visual Studio® update 2).
visual15.x
Analysis allows Microsoft Visual C++ 2017 syntax. For a list of available Microsoft Visual Studio 2017 versions, see Visual Studio 2017 Release Notes History.
visual16.x
Analysis allows Microsoft Visual C++ 2019 syntax. For a list of available Microsoft Visual Studio 2019 versions, see Visual Studio 2019 Release Notes History.
visual17.x
Analysis allows Microsoft Visual C++ 2022 syntax. For a list of available Microsoft Visual Studio 2022 versions, see Visual Studio 2022 Release Notes History.
Other Compilers
armcc - arm
Analysis allows non-ANSI® C syntax and semantics associated with the ARM® v5 compiler.
armclang - arm
Analysis allows non-ANSI C syntax and semantics associated with the ARM v6 compiler.
codewarrior - s12z
,codewarrior - powerpc
Analysis allows non-ANSI C syntax and semantics associated with the NXP CodeWarrior® compiler.
cosmic - s12z
Analysis allows non-ANSI C syntax and semantics associated with the Cosmic compiler.
diab - *
Analysis allows non-ANSI C syntax and semantics associated with the Wind River® Diab compiler.
generic
Analysis allows only standard syntax.
The language standard is determined by your choice for the following options:
If you do not specify a standard explicitly, the standard depends on your choice of compiler.
greenhills - *
Analysis allows non-ANSI C syntax and semantics associated with a Green Hills® compiler.
iar
Analysis allows non-ANSI C syntax and semantics associated with the compilers from IAR Systems (www.iar.com).
iar-ew - *
Analysis allows non-ANSI C syntax and semantics associated with the IAR Embedded Workbench compiler.
intel - x86_64
Analysis allows non-ANSI C syntax and semantics associated with the Intel® C++ Compiler Classic (icc/icl) compiler.
keil
Analysis allows non-ANSI C syntax and semantics associated with the Keil™ products from ARM (www.keil.com).
microchip
Analysis allows non-ANSI C syntax and semantics associated with the MPLAB XC8 C compiler.
renesas - *
Analysis allows non-ANSI C syntax and semantics associated with the Renesas® compiler.
tasking - *
Analysis allows non-ANSI C syntax and semantics associated with the TASKING compiler.
ti - *
Analysis allows non-ANSI C syntax and semantics associated with the Texas Instruments® compiler.
Tips
Your compiler specification determines the values of many compiler-specific macros. In case you want to know how Polyspace defines a specific macro, use the option
-dump-preprocessing-info
.To override the macro definition, use the option
Preprocessor definitions (-D)
.To undefine a macro, use the option
Disabled preprocessor definitions (-U)
.
If you use a Visual Studio compiler,set
long long
to 64 bits. SeeProcessor Details
. To setlong long
to 64 bit at the command line, use the option-long-long-is-64bits
.If you use the option
Check JSF AV C++ rules (-jsf-coding-rules)
, select the compilergeneric
. If you use another compiler, Polyspace cannot check the JSF® coding rules that require conforming to the ISO standard. For example, AV Rule 8: “All code shall conform to ISO/IEC 14882:2002(E) standard C++.”
Limitations
GNU Compilers
Polyspace does not support certain features of GNU compilers:
GNU® compilers versions 4.7 and later:
Nested functions.
For instance, the function
bar
is nested in functionfoo
:int foo (int a, int b) { int bar (int c) { return c * c; } return bar (a) + bar (b); }
Binary operations with vector types where one operand uses the shorthand notation for uniform vectors.
For instance, in the addition operation,
2+a
, 2 is used as a shorthand notation for {2,2,2,2}.typedef int v4si __attribute__ ((vector_size (16))); v4si res, a = {1,2,3,4}; res = 2 + a; /* means {2,2,2,2} + a */
Forward declaration of function parameters.
For instance, the parameter
len
is forward declared:void func (int len; char data[len][len], int len) { /* … */ }
Complex integer data types.
However, complex floating point data types are supported.
Initialization of structures with flexible array members using an initialization list.
For instance, the structure
S
has a flexible array membertab
. A variable of typeS
is directly initialized with an initialization list.You see a warning during analysis and a red check in the results when you dereference, for instance,struct S { int x; int tab[]; /* flexible array member - not supported */ }; struct S s = { 0, 1, 2} ;
s.tab[1]
.128-bit variables.
Polyspace cannot analyze this data type semantically. Bug Finder allows use of 128-bit data types, but Code Prover shows a compilation error if you use such a data type, for instance, the GCC extension
__float128
.
GNU compilers version 7.x:
Type names
_FloatN
and_FloatNx
are not semantically supported. The analysis treats them as typefloat
,double
, orlong double
.Constants of type
_FloatN
or_FloatNx
with suffixesfN
,FN
, orfNx
, such as1.2f123
or2.3F64x
are not supported.
Visual Studio Compilers
Polyspace does not support certain features of Visual Studio compilers:
C++ Accelerated Massive Parallelism (AMP).
C++ AMP is a Visual Studio feature that accelerates your C++ code execution for certain types of data-parallel hardware on specific targets. You typically use the
restrict
keyword to enable this feature.void Buffer() restrict(amp) { ... }
__assume
statements.You typically use
__assume
with a condition that is false. The statement indicates that the optimizer must assume the condition to be henceforth true. Code Prover cannot reconcile this contradiction. You get the error:Asked for compulsory presence of absent entity : assert
Managed Extensions for C++ (required for the .NET Framework), or its successor, C++/CLI (C++ modified for Common Language Infrastructure)
__declspec
keyword with attributes other thannoreturn
,nothrow
,selectany
orthread
.
Polyspace System Headers
If you do not specify the path to your compiler headers, Polyspace uses its own system headers and your project might not compile even if your code compiles with your compiler.
To make sure that Polyspace uses your compiler header files, run polyspace-configure
or specify the paths to your
compiler header files manually. See Provide Standard Library Headers for Polyspace Analysis.
Command-Line Information
Parameter: -compiler |
Value: armcc | armclang | clang3.x |
clang4.x | clang5.x | clang6.x | clang7.x | clang8.x | clang9.x | clang10.x |
clang11.x | clang12.x | clang13.x | codewarrior | cosmic | diab | generic | gnu3.4 |
gnu4.6 | gnu4.7 | gnu4.8 | gnu4.9 | gnu5.x | gnu6.x | gnu7.x | gnu8.x | gnu9.x |
gnu10.x | gnu11.x | gnu12.x | greenhills | iar | iar-ew | intel | keil | microchip |
renesas | tasking | ti | visual10.0 | visual11.0 | visual12.0 | visual14.0 |
visual15.x | visual16.x | visual9.0 |
Default:
generic |
Example 1 (Bug Finder):
polyspace-bug-finder -lang c -sources
|
Example 2 (Bug Finder):
polyspace-bug-finder -lang cpp -sources
|
Example 1 (Code Prover):
polyspace-code-prover -lang c -sources
|
Example 2 (Code Prover):
polyspace-code-prover -lang cpp -sources
|
Example 1 (Bug Finder
Server):
polyspace-bug-finder-server -lang c
-sources |
Example 2 (Bug Finder Server):
polyspace-bug-finder-server -lang cpp -sources
|
Example 1 (Code Prover
Server):
polyspace-code-prover-server -lang c
-sources |
Example 2 (Code Prover
Server):
polyspace-code-prover-server -lang cpp
-sources |